Changeset 28966

Show
Ignore:
Timestamp:
10.04.2014 14:39:33 (6 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.

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

Legend:

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

    r28295 r28966  
    187187        } 
    188188        this.converter = new XMLConverter(); 
    189         this.doc = this.converter.newDOM(); 
     189        this.doc = XMLConverter.newDOM(); 
    190190 
    191191        // the receptionist -the servlet will talk to this 
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/OAIServer.java

    r28884 r28966  
    184184            Communicator communicator = null; 
    185185            // we need to create the XML to configure the communicator 
    186             Document site_doc = this.converter.newDOM(); 
     186            Document site_doc = XMLConverter.newDOM(); 
    187187            Element site_elem = site_doc.createElement(GSXML.SITE_ELEM); 
    188188            site_elem.setAttribute(GSXML.TYPE_ATT, remote_site_type); 
     
    359359         
    360360        String verb = getVerb(query); 
    361         Document response_doc = this.converter.newDOM(); 
     361        Document response_doc = XMLConverter.newDOM(); 
    362362        Element xml_response = OAIXML.createBasicResponse(response_doc, verb, pairs); 
    363363        Element verb_elem = null; 
     
    389389        // The query is valid, we can now 
    390390        // compose the request message to the receptionist 
    391         Document request_doc = this.converter.newDOM(); 
     391        Document request_doc = XMLConverter.newDOM(); 
    392392        Element xml_message = request_doc.createElement(GSXML.MESSAGE_ELEM); 
    393393        Element xml_request = request_doc.createElement(GSXML.REQUEST_ELEM); 
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/SOAPServerlocalsite.java

    r25727 r28966  
    7878        Element new_req = GSXML.duplicateWithNewName(req.getOwnerDocument(), req, tag_name, true); 
    7979        Node n = mr.process(new_req); 
    80         Element r = XMLConverter.nodeToElement(n); 
     80        Element r = GSXML.nodeToElement(n); 
    8181        // add the namespace back on 
    8282        //Element new_res = r; 
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/collection/Collection.java

    r28878 r28966  
    3939import org.greenstone.gsdl3.util.SimpleMacroResolver; 
    4040import org.greenstone.gsdl3.util.UserContext; 
     41import org.greenstone.gsdl3.util.XMLConverter; 
    4142import org.greenstone.gsdl3.util.XMLTransformer; 
    4243import org.w3c.dom.Document; 
     
    9596    { 
    9697        super(); 
    97         this.description = this.doc.createElement(GSXML.COLLECTION_ELEM); 
     98        this.description = this.desc_doc.createElement(GSXML.COLLECTION_ELEM); 
    9899    } 
    99100 
     
    463464        } 
    464465 
    465         if (subset.equals(GSXML.METADATA_ELEM + GSXML.LIST_MODIFIER) || subset.equals(GSXML.DISPLAY_TEXT_ELEM + GSXML.LIST_MODIFIER) || subset.equals("libraryParamList")) 
     466        if (subset.equals(GSXML.METADATA_ELEM + GSXML.LIST_MODIFIER) || subset.equals(GSXML.DISPLAY_TEXT_ELEM + GSXML.LIST_MODIFIER) || subset.equals(GSXML.LIBRARY_PARAM_ELEM+GSXML.LIST_MODIFIER)) 
    466467        { 
    467468            configureLocalData(coll_config_elem); 
     
    482483     * @return the result Element - should be <response> 
    483484     */ 
    484     protected Element processMessage(Element request) 
     485  protected Element processMessage(Document result_doc, Element request) 
    485486    { 
    486487        String type = request.getAttribute(GSXML.TYPE_ATT); 
    487488        if (type.equals(GSXML.REQUEST_TYPE_FORMAT_STRING)) 
    488489        { 
    489             return processFormatStringRequest(request); 
     490          return processFormatStringRequest(result_doc, request); 
    490491        } 
    491492        else if (type.equals(GSXML.REQUEST_TYPE_SECURITY)) 
    492493        { 
    493             return processSecurityRequest(request); 
     494          return processSecurityRequest(result_doc, request); 
    494495        } 
    495496        else if (type.equals(GSXML.REQUEST_TYPE_FORMAT)) 
    496497        { 
    497             Element response = this.doc.createElement(GSXML.RESPONSE_ELEM); 
     498 
     499            Element response = result_doc.createElement(GSXML.RESPONSE_ELEM); 
    498500            response.setAttribute(GSXML.FROM_ATT, this.cluster_name); 
    499501            response.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_FORMAT); 
    500502            if (_globalFormat != null) 
    501503            { 
    502                 response.appendChild(this.doc.importNode(_globalFormat, true)); 
     504                response.appendChild(result_doc.importNode(_globalFormat, true)); 
    503505            } 
    504506            return response; 
    505507        } 
    506508        // unknown type 
    507         return super.processMessage(request); 
    508  
    509     } 
    510  
    511     protected Element processSecurityRequest(Element request) 
    512     { 
    513         Element response = this.doc.createElement(GSXML.RESPONSE_ELEM); 
     509        return super.processMessage(result_doc, request); 
     510 
     511    } 
     512 
     513  protected Element processSecurityRequest(Document result_doc, Element request) 
     514    { 
     515        Element response = result_doc.createElement(GSXML.RESPONSE_ELEM); 
    514516        response.setAttribute(GSXML.FROM_ATT, this.cluster_name); 
    515517        response.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_SECURITY); 
     
    523525        ArrayList<String> groups = getPermittedGroups(oid); 
    524526 
    525         Element groupList = this.doc.createElement(GSXML.GROUP_ELEM + GSXML.LIST_MODIFIER); 
     527        Element groupList = result_doc.createElement(GSXML.GROUP_ELEM + GSXML.LIST_MODIFIER); 
    526528        response.appendChild(groupList); 
    527529 
    528530        for (String groupName : groups) 
    529531        { 
    530             Element group = this.doc.createElement(GSXML.GROUP_ELEM); 
     532            Element group = result_doc.createElement(GSXML.GROUP_ELEM); 
    531533            groupList.appendChild(group); 
    532534            group.setAttribute(GSXML.NAME_ATT, groupName); 
     
    652654    protected String getFieldValue(String oid, String fieldName) 
    653655    { 
    654         Element metadataMessage = this.doc.createElement(GSXML.MESSAGE_ELEM); 
    655         Element metadataRequest = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, this.cluster_name + "/DocumentMetadataRetrieve", new UserContext()); 
     656      Document msg_doc = XMLConverter.newDOM(); 
     657        Element metadataMessage = msg_doc.createElement(GSXML.MESSAGE_ELEM); 
     658        Element metadataRequest = GSXML.createBasicRequest(msg_doc, GSXML.REQUEST_TYPE_PROCESS, this.cluster_name + "/DocumentMetadataRetrieve", new UserContext()); 
    656659        metadataMessage.appendChild(metadataRequest); 
    657660 
    658         Element paramList = this.doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER); 
     661        Element paramList = msg_doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER); 
    659662        metadataRequest.appendChild(paramList); 
    660663 
    661         Element param = this.doc.createElement(GSXML.PARAM_ELEM); 
     664        Element param = msg_doc.createElement(GSXML.PARAM_ELEM); 
    662665        paramList.appendChild(param); 
    663666 
     
    665668        param.setAttribute(GSXML.VALUE_ATT, fieldName); 
    666669 
    667         Element docList = this.doc.createElement(GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER); 
     670        Element docList = msg_doc.createElement(GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER); 
    668671        metadataRequest.appendChild(docList); 
    669672 
    670         Element doc = this.doc.createElement(GSXML.DOC_NODE_ELEM); 
     673        Element doc = msg_doc.createElement(GSXML.DOC_NODE_ELEM); 
    671674        docList.appendChild(doc); 
    672675 
     
    685688    } 
    686689 
    687     protected Element processFormatStringRequest(Element request) 
    688     { 
    689         Element response = this.doc.createElement(GSXML.RESPONSE_ELEM); 
     690  protected Element processFormatStringRequest(Document result_doc, Element request) 
     691    { 
     692        Element response = result_doc.createElement(GSXML.RESPONSE_ELEM); 
    690693        response.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_FORMAT_STRING); 
    691694        response.setAttribute(GSXML.FROM_ATT, this.cluster_name); 
     
    834837                int index; 
    835838                Element elem; 
    836                 // Try importing entire tree to this.doc so we can add and remove children at ease 
    837                 //Node current_node = this.doc.importNode(GSXML.getChildByTagName(config, "CollectionConfig"),true); 
    838839                Node current_node = GSXML.getChildByTagName(config, "CollectionConfig"); 
    839840                NodeList current_node_list; 
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/collection/ServiceCluster.java

    r27940 r28966  
    8383  protected SimpleMacroResolver macro_resolver = null; 
    8484 
    85     /** container doc for description elements */ 
    86     protected Document doc = null; 
     85    /** container doc for description elements  
     86     only use this document for creating the below stored lists. */ 
     87        protected Document desc_doc = null; 
    8788    /** list of services */ 
    8889    protected Element service_list = null; 
     
    139140        this.converter = new XMLConverter(); 
    140141        this.macro_resolver = new SimpleMacroResolver(); 
    141         this.doc = this.converter.newDOM(); 
    142         this.description = this.doc.createElement(GSXML.CLUSTER_ELEM); 
    143         this.display_item_list = this.doc.createElement(GSXML.DISPLAY_TEXT_ELEM + GSXML.LIST_MODIFIER); 
    144         this.metadata_list = this.doc.createElement(GSXML.METADATA_ELEM + GSXML.LIST_MODIFIER); 
    145         this.library_param_list = this.doc.createElement("libraryParamList"); 
    146         this.service_list = this.doc.createElement(GSXML.SERVICE_ELEM + GSXML.LIST_MODIFIER); 
    147         //this.plugin_item_list = this.doc.createElement(GSXML.PLUGIN_ELEM + GSXML.LIST_MODIFIER); 
     142        this.desc_doc = XMLConverter.newDOM(); 
     143        this.description = this.desc_doc.createElement(GSXML.CLUSTER_ELEM); 
     144        this.display_item_list = this.desc_doc.createElement(GSXML.DISPLAY_TEXT_ELEM + GSXML.LIST_MODIFIER); 
     145        this.metadata_list = this.desc_doc.createElement(GSXML.METADATA_ELEM + GSXML.LIST_MODIFIER); 
     146        this.library_param_list = this.desc_doc.createElement(GSXML.LIBRARY_PARAM_ELEM+GSXML.LIST_MODIFIER); 
     147        this.service_list = this.desc_doc.createElement(GSXML.SERVICE_ELEM + GSXML.LIST_MODIFIER); 
     148        //this.plugin_item_list = this.desc_doc.createElement(GSXML.PLUGIN_ELEM + GSXML.LIST_MODIFIER); 
    148149    } 
    149150 
     
    266267 
    267268        // get the servlet params 
    268         Element param_list = (Element) GSXML.getChildByTagName(service_cluster_info, "libraryParamList"); 
     269        Element param_list = (Element) GSXML.getChildByTagName(service_cluster_info, GSXML.LIBRARY_PARAM_ELEM+GSXML.LIST_MODIFIER); 
    269270        if (param_list != null) { 
    270271          if (!addLibraryParams(param_list)) { 
     
    286287            for (int k = 0; k < metanodes.getLength(); k++) 
    287288            { 
    288                 this.metadata_list.appendChild(this.doc.importNode(metanodes.item(k), true)); 
     289                this.metadata_list.appendChild(this.desc_doc.importNode(metanodes.item(k), true)); 
    289290            } 
    290291        } 
     
    294295  /** adds an individual metadata element into the list */ 
    295296  protected boolean addMetadata(String name, String value) { 
    296     return GSXML.addMetadata(this.doc, this.metadata_list, name, value); 
     297    return GSXML.addMetadata(this.metadata_list, name, value); 
    297298  } 
    298299   
     
    324325                if (this_item == null) 
    325326                { 
    326                     this_item = this.doc.createElement(GSXML.DISPLAY_TEXT_ELEM); 
     327                    this_item = this.desc_doc.createElement(GSXML.DISPLAY_TEXT_ELEM); 
    327328                    this_item.setAttribute(GSXML.NAME_ATT, name); 
    328329                    this.display_item_list.appendChild(this_item); 
    329330                } 
    330331 
    331                 this_item.appendChild(this.doc.importNode(d, true)); 
     332                this_item.appendChild(this.desc_doc.importNode(d, true)); 
    332333            } 
    333334        } 
     
    385386            for (int k = 0; k < paramnodes.getLength(); k++) 
    386387            { 
    387                 this.library_param_list.appendChild(this.doc.importNode(paramnodes.item(k), true)); 
     388                this.library_param_list.appendChild(this.desc_doc.importNode(paramnodes.item(k), true)); 
    388389            } 
    389390        } 
     
    396397        service_map.clear(); 
    397398        service_name_map.clear(); 
    398         this.service_list = this.doc.createElement(GSXML.SERVICE_ELEM + GSXML.LIST_MODIFIER); 
     399        this.service_list = this.desc_doc.createElement(GSXML.SERVICE_ELEM + GSXML.LIST_MODIFIER); 
    399400    } 
    400401 
    401402  protected void clearLocalData() { 
    402     this.description = this.doc.createElement(GSXML.CLUSTER_ELEM); 
    403     this.display_item_list = this.doc.createElement(GSXML.DISPLAY_TEXT_ELEM + GSXML.LIST_MODIFIER); 
    404     this.metadata_list = this.doc.createElement(GSXML.METADATA_ELEM + GSXML.LIST_MODIFIER); 
    405     this.library_param_list = this.doc.createElement("libraryParamList"); 
     403    this.description = this.desc_doc.createElement(GSXML.CLUSTER_ELEM); 
     404    this.display_item_list = this.desc_doc.createElement(GSXML.DISPLAY_TEXT_ELEM + GSXML.LIST_MODIFIER); 
     405    this.metadata_list = this.desc_doc.createElement(GSXML.METADATA_ELEM + GSXML.LIST_MODIFIER); 
     406    this.library_param_list = this.desc_doc.createElement(GSXML.LIBRARY_PARAM_ELEM+GSXML.LIST_MODIFIER); 
    406407  
    407408  } 
     
    422423        } 
    423424 
     425        // the xml request to send to the serviceRacks to query what 
     426        // services they provide 
     427        // can send same message to each service rack 
     428        Document doc = XMLConverter.newDOM(); 
     429        Element message = doc.createElement(GSXML.MESSAGE_ELEM); 
     430        Element request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_DESCRIBE, "", new UserContext()); 
     431        message.appendChild(request); 
    424432        for (int i = 0; i < nodes.getLength(); i++) 
    425433        { 
    426434 
    427             // the xml request to send to the serviceRack to query what 
    428             // services it provides 
    429             Element message = this.doc.createElement(GSXML.MESSAGE_ELEM); 
    430             Element request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, "", new UserContext()); 
    431             message.appendChild(request); 
    432435 
    433436            Element n = (Element) nodes.item(i); 
     
    499502                    this.service_map.put(service, s); 
    500503                    // also add info to the ServiceInfo XML element 
    501                     this.service_list.appendChild(this.doc.importNode(typenodes.item(j), true)); 
     504                    this.service_list.appendChild(this.desc_doc.importNode(typenodes.item(j), true)); 
    502505                } 
    503506            } 
     
    532535    public Node process(Node message_node) 
    533536    { 
    534         Element message = this.converter.nodeToElement(message_node); 
     537        Element message = GSXML.nodeToElement(message_node); 
    535538 
    536539        NodeList requests = message.getElementsByTagName(GSXML.REQUEST_ELEM); 
    537540        Document mess_doc = message.getOwnerDocument(); 
    538         Element mainResult = this.doc.createElement(GSXML.MESSAGE_ELEM); 
     541        Document result_doc = XMLConverter.newDOM(); 
     542        Element mainResult = result_doc.createElement(GSXML.MESSAGE_ELEM); 
    539543        if (requests.getLength() == 0) 
    540544        { 
     
    560564            if (to.equals("")) 
    561565            { // this command is for me 
    562                 Element response = processMessage(request); 
     566              Element response = processMessage(result_doc, request); 
    563567                mainResult.appendChild(response); 
    564568 
     
    606610                    from = GSPath.prependLink(from, this.cluster_name); 
    607611                    response.setAttribute(GSXML.FROM_ATT, from); 
    608                     mainResult.appendChild(this.doc.importNode(response, true)); 
     612                    mainResult.appendChild(result_doc.importNode(response, true)); 
    609613                } 
    610614 
     
    622626     * @return the result Element - should be <response> 
    623627     */ 
    624     protected Element processMessage(Element request) 
    625     { 
    626         Element response = this.doc.createElement(GSXML.RESPONSE_ELEM); 
     628  protected Element processMessage(Document result_doc, Element request) 
     629    { 
     630 
     631        Element response = result_doc.createElement(GSXML.RESPONSE_ELEM); 
    627632        response.setAttribute(GSXML.FROM_ATT, this.cluster_name); 
    628633        String type = request.getAttribute(GSXML.TYPE_ATT); 
     
    633638        { 
    634639            // create the collection element 
    635             Element description = (Element) this.description.cloneNode(false); 
     640          Element description = (Element) result_doc.importNode(this.description, false); 
    636641            // set collection type : mg, mgpp, lucene or solr 
    637642            //description.setAttribute(GSXML.TYPE_ATT, col_type); 
     
    644649            { 
    645650                addAllDisplayInfo(description, lang); 
    646                 description.appendChild(this.service_list); 
    647                 description.appendChild(this.metadata_list); 
    648                 description.appendChild(this.library_param_list); 
     651                description.appendChild(result_doc.importNode(this.service_list, true)); 
     652                description.appendChild(result_doc.importNode(this.metadata_list, true)); 
     653                description.appendChild(result_doc.importNode(this.library_param_list, true)); 
    649654                //description.appendChild(this.plugin_item_list); 
    650655                return response; 
     
    663668                    if (info.equals(GSXML.SERVICE_ELEM + GSXML.LIST_MODIFIER)) 
    664669                    { 
    665                         description.appendChild(this.service_list); 
     670                      description.appendChild(result_doc.importNode(this.service_list, true)); 
    666671                    } 
    667672                    else if (info.equals(GSXML.METADATA_ELEM + GSXML.LIST_MODIFIER)) 
    668673                    { 
    669                         description.appendChild(this.metadata_list); 
     674                      description.appendChild(result_doc.importNode(this.metadata_list, true)); 
    670675                    } 
    671676                    else if (info.equals(GSXML.DISPLAY_TEXT_ELEM + GSXML.LIST_MODIFIER)) 
     
    673678                        addAllDisplayInfo(description, lang); 
    674679                    } 
    675                     else if (info.equals("libraryParamlist")) 
     680                    else if (info.equals(GSXML.LIBRARY_PARAM_ELEM+GSXML.LIST_MODIFIER)) 
    676681                    { 
    677                       description.appendChild(this.library_param_list); 
     682                      description.appendChild(result_doc.importNode(this.library_param_list, true)); 
    678683                    } 
    679684                } 
     
    778783    protected Element processSystemRequest(Element request) 
    779784    { 
    780  
    781         Element response = this.doc.createElement(GSXML.RESPONSE_ELEM); 
     785      Document result_doc = XMLConverter.newDOM(); 
     786        Element response = result_doc.createElement(GSXML.RESPONSE_ELEM); 
    782787        response.setAttribute(GSXML.FROM_ATT, this.cluster_name); 
    783788        response.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_SYSTEM); 
     
    801806                    if (this.configure()) 
    802807                    { 
    803                         Element s = GSXML.createTextElement(this.doc, GSXML.STATUS_ELEM, this.cluster_name + " reconfigured"); 
     808                        Element s = GSXML.createTextElement(result_doc, GSXML.STATUS_ELEM, this.cluster_name + " reconfigured"); 
    804809                        response.appendChild(s); 
    805810 
     
    807812                    else 
    808813                    { 
    809                         Element s = GSXML.createTextElement(this.doc, GSXML.STATUS_ELEM, this.cluster_name + " could not be reconfigured"); 
     814                        Element s = GSXML.createTextElement(result_doc, GSXML.STATUS_ELEM, this.cluster_name + " could not be reconfigured"); 
    810815                        response.appendChild(s); 
    811816                    } 
     
    813818                else if (this.configureSubset(subset)) 
    814819                { 
    815                     Element s = GSXML.createTextElement(this.doc, GSXML.STATUS_ELEM, this.cluster_name + " " + subset + " reconfigured"); 
     820                    Element s = GSXML.createTextElement(result_doc, GSXML.STATUS_ELEM, this.cluster_name + " " + subset + " reconfigured"); 
    816821                    response.appendChild(s); 
    817822                } 
    818823                else 
    819824                { 
    820                     Element s = GSXML.createTextElement(this.doc, GSXML.STATUS_ELEM, this.cluster_name + " " + subset + " could not be reconfigured"); 
     825                    Element s = GSXML.createTextElement(result_doc, GSXML.STATUS_ELEM, this.cluster_name + " " + subset + " could not be reconfigured"); 
    821826                    response.appendChild(s); 
    822827                } 
     
    828833            if (action.equals(GSXML.SYSTEM_TYPE_ACTIVATE)) 
    829834            { 
    830                 Element s = GSXML.createTextElement(this.doc, GSXML.STATUS_ELEM, "activate action not yet implemented - does it even make sense in this context??"); 
     835                Element s = GSXML.createTextElement(result_doc, GSXML.STATUS_ELEM, "activate action not yet implemented - does it even make sense in this context??"); 
    831836                response.appendChild(s); 
    832837            } 
     
    846851                    message = "Can't deactivate " + module_type + " type modules!"; 
    847852                } 
    848                 Element s = GSXML.createTextElement(this.doc, GSXML.STATUS_ELEM, message); 
     853                Element s = GSXML.createTextElement(result_doc, GSXML.STATUS_ELEM, message); 
    849854                response.appendChild(s); 
    850855            } 
     
    897902        else if (subset.equals(GSXML.METADATA_ELEM + GSXML.LIST_MODIFIER)) 
    898903        { 
    899             this.metadata_list = this.doc.createElement(GSXML.METADATA_ELEM + GSXML.LIST_MODIFIER); 
     904            this.metadata_list = this.desc_doc.createElement(GSXML.METADATA_ELEM + GSXML.LIST_MODIFIER); 
    900905            Element metadata_list = (Element) GSXML.getChildByTagName(cluster_config_elem, GSXML.METADATA_ELEM + GSXML.LIST_MODIFIER); 
    901906            return addMetadata(metadata_list); 
     
    923928    protected boolean addAllDisplayInfo(Element description, String lang) 
    924929    { 
    925  
     930      Document doc = description.getOwnerDocument(); 
    926931        NodeList items = this.display_item_list.getChildNodes(); 
    927932        for (int i = 0; i < items.getLength(); i++) 
     
    940945                new_m = (Element) GSXML.getChildByTagName(m, GSXML.DISPLAY_TEXT_ELEM); 
    941946            } 
    942             description.appendChild(new_m.cloneNode(true)); 
     947            description.appendChild(doc.importNode(new_m, true)); 
    943948        } 
    944949        return true; 
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/collection/XMLCollection.java

    r26446 r28966  
    3030                      Element build_config_xml){ 
    3131 
    32     // metadata 
     32    // add metadata to stored metadata list from collConfig and buildConfig 
    3333    Element meta_list = (Element)GSXML.getChildByTagName(coll_config_xml, GSXML.METADATA_ELEM+GSXML.LIST_MODIFIER); 
    3434    addMetadata(meta_list); 
     
    3636    addMetadata(meta_list); 
    3737 
    38     meta_list = this.doc.createElement(GSXML.METADATA_ELEM + GSXML.LIST_MODIFIER); 
    39     GSXML.addMetadata(this.doc, meta_list, "httpPath", this.site_http_address+"/collect/"+this.cluster_name); 
    40     addMetadata(meta_list); 
     38    addMetadata("httpPath", this.site_http_address+"/collect/"+this.cluster_name); 
    4139 
    4240    // display stuff 
     
    4745    } 
    4846 
    49     //plugin stuff 
    50     // Element import_list = (Element)GSXML.getChildByTagName(coll_config_xml, GSXML.IMPORT_ELEM); 
    51     // if (import_list != null) 
    52     // { 
    53     //  Element plugin_list = (Element)GSXML.getChildByTagName(import_list, GSXML.PLUGIN_ELEM+GSXML.LIST_MODIFIER); 
    54     //  addPlugins(plugin_list); 
    55     // } 
    56      
    5747    // are we a private collection?? 
    5848    if (this.metadata_list != null) { 
     
    6959    Element config_doc_list = (Element)GSXML.getChildByTagName(coll_config_xml, GSXML.DOCUMENT_ELEM+GSXML.LIST_MODIFIER); 
    7060    if (config_doc_list != null) { 
    71         document_list = (Element)this.doc.importNode(config_doc_list, true); 
     61        document_list = (Element)desc_doc.importNode(config_doc_list, true); 
    7262    } else { 
    73         document_list = this.doc.createElement(GSXML.DOCUMENT_ELEM+GSXML.LIST_MODIFIER); 
     63        document_list = desc_doc.createElement(GSXML.DOCUMENT_ELEM+GSXML.LIST_MODIFIER); 
    7464    } 
    7565    return true; 
     
    8272     * @return the result Element - should be <response> 
    8373     */ 
    84     protected Element processMessage(Element request) { 
     74  protected Element processMessage(Document response_doc, Element request) { 
    8575 
    86     Element response = this.doc.createElement(GSXML.RESPONSE_ELEM); 
     76    Element response = response_doc.createElement(GSXML.RESPONSE_ELEM); 
    8777    response.setAttribute(GSXML.FROM_ATT, this.cluster_name); 
    8878    String type = request.getAttribute(GSXML.TYPE_ATT); 
     
    9282    if (type.equals(GSXML.REQUEST_TYPE_DESCRIBE)) { 
    9383        // create the collection element 
    94         Element description = (Element)this.description.cloneNode(false); 
     84      Element description = (Element)response_doc.importNode(this.description, false); 
    9585        response.appendChild(description); 
    9686        // check the param list 
     
    9888        if (param_list == null) { 
    9989        addAllDisplayInfo(description, lang); 
    100         description.appendChild(this.service_list); 
    101         description.appendChild(this.metadata_list); 
    102         description.appendChild(this.library_param_list); 
    103         description.appendChild(this.document_list); 
     90        description.appendChild(response_doc.importNode(this.service_list, true)); 
     91        description.appendChild(response_doc.importNode(this.metadata_list, true)); 
     92        description.appendChild(response_doc.importNode(this.library_param_list, true)); 
     93        description.appendChild(response_doc.importNode(this.document_list, true)); 
    10494        return response; 
    10595        } 
     
    114104            String info = param.getAttribute(GSXML.VALUE_ATT); 
    115105            if (info.equals(GSXML.SERVICE_ELEM+GSXML.LIST_MODIFIER)) { 
    116             description.appendChild(this.service_list); 
     106            description.appendChild(response_doc.importNode(this.service_list, true)); 
    117107            } else if (info.equals(GSXML.METADATA_ELEM+GSXML.LIST_MODIFIER)) { 
    118             description.appendChild(metadata_list); 
     108            description.appendChild(response_doc.importNode(metadata_list, true)); 
    119109            } else if (info.equals(GSXML.DISPLAY_TEXT_ELEM+GSXML.LIST_MODIFIER)) { 
    120110            addAllDisplayInfo(description, lang); 
    121111             
    122112            } else if (info.equals(GSXML.DOCUMENT_ELEM+GSXML.LIST_MODIFIER)) { 
    123             description.appendChild(this.document_list); 
    124             // } else if (info.equals(GSXML.PLUGIN_ELEM+GSXML.LIST_MODIFIER)) { 
    125             //  description.appendChild(this.plugin_item_list); 
    126             // } 
    127             } else if (info.equals("libraryParamlist")) { 
     113            description.appendChild(response_doc.importNode(this.document_list, true)); 
     114            } else if (info.equals(GSXML.LIBRARY_PARAM_ELEM+GSXML.LIST_MODIFIER)) { 
    128115               
    129               description.appendChild(this.library_param_list); 
     116            description.appendChild(response_doc.importNode(this.library_param_list, true)); 
    130117            } 
    131118         
     
    134121        return response; 
    135122    } 
    136     return super.processMessage(request); 
     123    return super.processMessage(response_doc, request); 
    137124         
    138125    } 
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/comms/SOAPCommunicator.java

    r25727 r28966  
    9696    public Node process(Node message_node) { 
    9797     
    98     Element message = XMLConverter.nodeToElement(message_node); 
     98    Element message = GSXML.nodeToElement(message_node); 
    9999 
    100100    NodeList requests = message.getElementsByTagName(GSXML.REQUEST_ELEM); 
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/core/DefaultReceptionist.java

    r24993 r28966  
    2929    { 
    3030        super.addExtraInfo(page); 
    31  
     31        // the document for the page 
     32        Document doc = page.getOwnerDocument(); 
     33        // a new document to create messages to send to MR 
     34        Document msg_doc = XMLConverter.newDOM(); 
    3235        Element page_request = (Element) GSXML.getChildByTagName(page, GSXML.PAGE_REQUEST_ELEM); 
    3336        // if it is a system request, then we don't bother with this. 
     
    7073        if (this.language_list != null) 
    7174        { 
    72             page_response.appendChild(this.language_list); 
     75          page_response.appendChild(doc.importNode(this.language_list, true)); 
    7376        } 
    7477        Element coll_description = (Element) GSXML.getChildByTagName(page_response, GSXML.COLLECTION_ELEM); 
     
    8083        if (coll_description == null) 
    8184        { 
    82  
     85          logger.debug("getting the coll description"); 
    8386            // we dont have one yet - get it 
    84             Element coll_about_message = this.doc.createElement(GSXML.MESSAGE_ELEM); 
    85             Element coll_about_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, coll_name, userContext); 
     87 
     88            Element coll_about_message = msg_doc.createElement(GSXML.MESSAGE_ELEM); 
     89            Element coll_about_request = GSXML.createBasicRequest(msg_doc, GSXML.REQUEST_TYPE_DESCRIBE, coll_name, userContext); 
    8690            coll_about_message.appendChild(coll_about_request); 
    8791 
     
    104108            } 
    105109            // have found one, append it to the page response 
    106             coll_description = (Element) this.doc.importNode(coll_description, true); 
     110            coll_description = (Element) doc.importNode(coll_description, true); 
    107111            page_response.appendChild(coll_description); 
    108112            get_service_description = true; 
    109113        } 
     114         
    110115 
    111116        // have got a coll description 
     
    151156 
    152157        // we will send all the requests in a single message 
    153         Element info_message = this.doc.createElement(GSXML.MESSAGE_ELEM); 
     158        Element info_message = msg_doc.createElement(GSXML.MESSAGE_ELEM); 
    154159        for (int i = 0; i < services.getLength(); i++) 
    155160        { 
     
    157162            String name = c.getAttribute(GSXML.NAME_ATT); 
    158163            String address = GSPath.appendLink(coll_name, name); 
    159             Element info_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, address, userContext); 
     164            Element info_request = GSXML.createBasicRequest(msg_doc, GSXML.REQUEST_TYPE_DESCRIBE, address, userContext); 
    160165            //Element req_param_list = this.doc.createElement(GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER); 
    161166            //req_param_list.appendChild(GSXML.createParameter(this.doc, GSXML.SUBSET_PARAM, GSXML.DISPLAY_TEXT_ELEM+GSXML.LIST_MODIFIER)); 
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/core/MessageRouter.java

    r28856 r28966  
    235235    { 
    236236 
    237       Document doc = this.converter.newDOM(); 
    238         Element message = this.converter.nodeToElement(message_node); 
     237      Document doc = XMLConverter.newDOM(); 
     238        Element message = GSXML.nodeToElement(message_node); 
    239239 
    240240        // check that its a correct message tag 
     
    464464 
    465465        // load up the services: serviceRackList 
    466         Document doc = this.converter.newDOM(); 
     466        Document doc = XMLConverter.newDOM(); 
    467467        this.service_list = doc.createElement(GSXML.SERVICE_ELEM + GSXML.LIST_MODIFIER); 
    468468        Element service_rack_list_elem = (Element) GSXML.getChildByTagName(config_info, GSXML.SERVICE_CLASS_ELEM + GSXML.LIST_MODIFIER); 
     
    512512            return true; 
    513513        } 
    514         Document doc = this.converter.newDOM(); 
     514        Document doc = XMLConverter.newDOM(); 
    515515        Element service_message = doc.createElement(GSXML.MESSAGE_ELEM); 
    516516        Element service_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_DESCRIBE, "", new UserContext()); 
     
    916916 
    917917        logger.info(" getting info from site:" + site_name); 
    918         Document doc = this.converter.newDOM(); 
     918        Document doc = XMLConverter.newDOM(); 
    919919        Element info_request = doc.createElement(GSXML.MESSAGE_ELEM); 
    920920        Element req = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_DESCRIBE, "", new UserContext()); 
     
    923923        // process the message 
    924924        Node info_response_node = comm.process(info_request); 
    925         Element info_response = converter.nodeToElement(info_response_node); 
     925        Element info_response = GSXML.nodeToElement(info_response_node); 
    926926 
    927927        if (info_response == null) 
     
    10831083 
    10841084        // message for self, should be type=describe/configure at this stage 
    1085             Document doc = this.converter.newDOM(); 
     1085            Document doc = XMLConverter.newDOM(); 
    10861086        String type = req.getAttribute(GSXML.TYPE_ATT); 
    10871087        Element response = doc.createElement(GSXML.RESPONSE_ELEM); 
     
    13341334    protected Element modifyMessages(Element request, Element message, Element result) 
    13351335    { 
    1336       Document doc = this.converter.newDOM(); 
     1336      Document doc = XMLConverter.newDOM(); 
    13371337        Element response = doc.createElement(GSXML.RESPONSE_ELEM); 
    13381338        response.setAttribute(GSXML.FROM_ATT, ""); 
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/core/OAIReceptionist.java

    r28885 r28966  
    178178    // First, we get a list of all the OAI enabled collections 
    179179    // We get this by sending a listSets request to the MR 
    180     Document doc = this.converter.newDOM(); 
     180    Document doc = XMLConverter.newDOM(); 
    181181    Element message = doc.createElement(GSXML.MESSAGE_ELEM); 
    182182     
     
    228228      return false; 
    229229    } 
    230     Document listsets_doc = this.converter.newDOM(); 
     230    Document listsets_doc = XMLConverter.newDOM(); 
    231231    Element listsets_element = listsets_doc.createElement(OAIXML.LIST_SETS); 
    232232    this.listsets_response = getMessage(listsets_doc, listsets_element); 
     
    285285  protected void resetMessageRouter() { 
    286286    // we just need to send a configure request to MR 
    287     Document doc = this.converter.newDOM(); 
     287    Document doc = XMLConverter.newDOM(); 
    288288    Element mr_request_message = doc.createElement(GSXML.MESSAGE_ELEM); 
    289289    Element mr_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_SYSTEM, "", null); 
     
    321321    logger.error("OAIReceptionist received request"); 
    322322 
    323     Element message = this.converter.nodeToElement(message_node); 
     323    Element message = GSXML.nodeToElement(message_node); 
    324324    logger.error(this.converter.getString(message)); 
    325325 
     
    413413    valid_strs.add(OAIXML.RESUMPTION_TOKEN); 
    414414     
    415     Document result_doc = this.converter.newDOM(); 
     415    Document result_doc = XMLConverter.newDOM(); 
    416416    Element result_element = result_doc.createElement(verb); 
    417417    boolean result_token_needed = false; // does this result need to include a 
     
    538538 
    539539 
    540     Document doc = this.converter.newDOM(); 
     540    Document doc = XMLConverter.newDOM(); 
    541541    Element mr_msg = doc.createElement(GSXML.MESSAGE_ELEM); 
    542542    Element mr_req = doc.createElement(GSXML.REQUEST_ELEM); 
     
    767767    NodeList params = GSXML.getChildrenByTagName(req, GSXML.PARAM_ELEM); 
    768768    Element param = null; 
    769     Document lmf_doc = this.converter.newDOM(); 
     769    Document lmf_doc = XMLConverter.newDOM(); 
    770770    if(params.getLength() == 0) { 
    771771      //this is requesting metadata formats for the whole repository 
     
    852852    //Now send the request to the message router to process 
    853853    Node result_node = mr.process(message); 
    854     return converter.nodeToElement(result_node); 
     854    return GSXML.nodeToElement(result_node); 
    855855  } 
    856856   
     
    877877      return getMessage(this.identify_response.getOwnerDocument(), this.identify_response); 
    878878    } 
    879     Document doc = this.converter.newDOM(); 
     879    Document doc = XMLConverter.newDOM(); 
    880880    Element identify = doc.createElement(OAIXML.IDENTIFY); 
    881881    //do the repository name 
     
    979979    *  Exceptions: badArgument; cannotDisseminateFormat; idDoesNotExist 
    980980    */  
    981     Document doc = this.converter.newDOM(); 
     981    Document doc = XMLConverter.newDOM(); 
    982982    Element get_record = doc.createElement(OAIXML.GET_RECORD); 
    983983 
     
    10311031    msg.appendChild(doc.importNode(req, true)); 
    10321032    Node result_node = mr.process(msg); 
    1033     return converter.nodeToElement(result_node); 
     1033    return GSXML.nodeToElement(result_node); 
    10341034  } 
    10351035 
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/core/Receptionist.java

    r28248 r28966  
    3333    protected HashMap<String, Object> config_params = null; 
    3434    /** container Document to create XML Nodes */ 
    35     protected Document doc = null; 
     35    //protected Document doc = null; 
    3636 
    3737    /** a converter class to parse XML and create Docs */ 
     
    5454    { 
    5555        this.converter = new XMLConverter(); 
    56         this.doc = this.converter.newDOM(); 
     56        //this.doc = XMLConverter.newDOM(); 
    5757        this.action_map = new HashMap<String, Action>(); 
    5858    } 
     
    182182    public Node process(Node message_node) 
    183183    { 
    184         Element message = this.converter.nodeToElement(message_node); 
     184        Element message = GSXML.nodeToElement(message_node); 
    185185 
    186186        // get the request out of the message - assume that there is only one 
     
    242242        preProcessRequest(request); 
    243243        // set up the page 
    244         Element page = this.doc.createElement(GSXML.PAGE_ELEM); 
     244        Document doc = XMLConverter.newDOM(); 
     245        Element page = doc.createElement(GSXML.PAGE_ELEM); 
    245246        page.setAttribute(GSXML.LANG_ATT, request.getAttribute(GSXML.LANG_ATT)); 
    246247        // just in case these namespaces end up in the page and we want to display the XML 
     
    273274 
    274275        // the request is part of the page 
    275         page.appendChild(GSXML.duplicateWithNewName(this.doc, request, GSXML.PAGE_REQUEST_ELEM, true)); 
     276        page.appendChild(GSXML.duplicateWithNewName(doc, request, GSXML.PAGE_REQUEST_ELEM, true)); 
    276277        // add the response too 
    277         Element page_response = GSXML.duplicateWithNewName(this.doc, (Element) GSXML.getChildByTagName(action_response, GSXML.RESPONSE_ELEM), GSXML.PAGE_RESPONSE_ELEM, true); 
     278        Element page_response = GSXML.duplicateWithNewName(doc, (Element) GSXML.getChildByTagName(action_response, GSXML.RESPONSE_ELEM), GSXML.PAGE_RESPONSE_ELEM, true); 
    278279        page.appendChild(page_response); 
    279280 
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/core/TransformingReceptionist.java

    r28257 r28966  
    179179        else 
    180180        { 
    181             this.language_list = (Element) this.doc.importNode(lang_list, true); 
     181          //this.language_list = (Element) this.doc.importNode(lang_list, true); 
     182          this.language_list = lang_list; 
    182183        } 
    183184 
     
    380381        ArrayList<File> stylesheets = GSFile.getStylesheetFiles(GlobalProperties.getGSDL3Home(), (String) this.config_params.get(GSConstants.SITE_NAME), collection, (String) this.config_params.get(GSConstants.INTERFACE_NAME), base_interfaces, name); 
    381382 
    382         Element extraMetadataList = this.doc.createElement(GSXML.EXTRA_METADATA + GSXML.LIST_MODIFIER); 
     383        Document doc = XMLConverter.newDOM(); 
     384        Element extraMetadataList = doc.createElement(GSXML.EXTRA_METADATA + GSXML.LIST_MODIFIER); 
    383385        for (File stylesheet : stylesheets) 
    384386        { 
     
    389391                for (String metadataString : requiredMetadata) 
    390392                { 
    391                     Element metadataElem = this.doc.createElement(GSXML.EXTRA_METADATA); 
     393                    Element metadataElem = doc.createElement(GSXML.EXTRA_METADATA); 
    392394                    metadataElem.setAttribute(GSXML.NAME_ATT, metadataString); 
    393395                    extraMetadataList.appendChild(metadataElem); 
     
    701703        if (style_doc == null) 
    702704        { 
    703             String errorPage = this.converter.getParseErrorMessage(); 
    704             if (errorPage != null) 
    705             { 
    706                 return XMLTransformer.constructErrorXHTMLPage("Cannot parse the xslt file\n" + errorPage); 
    707             } 
     705          // this getParseErrorMessage may have originally worked, but now it doesn't. 
     706          // //String errorPage = this.converter.getParseErrorMessage(); 
     707          //    if (errorPage != null) 
     708          //    { 
     709          //      return XMLTransformer.constructErrorXHTMLPage("Cannot parse the xslt file\n");// + errorPage); 
     710          //    } 
    708711            return page; 
    709712        } 
     
    712715        // the paths right if you have paths relative to the document root 
    713716        // eg /page. 
    714         Document doc = this.converter.newDOM(); 
     717        Document doc = XMLConverter.newDOM(); 
    715718        doc.appendChild(doc.importNode(page, true)); 
    716719        Element page_response = (Element) GSXML.getChildByTagName(page, GSXML.PAGE_RESPONSE_ELEM); 
     
    743746            if (configStylesheet_doc != null) 
    744747            { 
    745                 Document format_doc = this.converter.newDOM(); 
     748                Document format_doc = XMLConverter.newDOM(); 
    746749                format_doc.appendChild(format_doc.importNode(format_elem, true)); 
    747750 
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/AbstractBrowse.java

    r26046 r28966  
    2929import org.greenstone.gsdl3.util.MacroResolver; 
    3030import org.greenstone.gsdl3.util.OID; 
     31import org.greenstone.gsdl3.util.XMLConverter; 
     32 
    3133import org.w3c.dom.Document; 
    3234import org.w3c.dom.Element; 
     
    113115 
    114116        // short_service_info_ - the browse one 
    115         Element cb_service = this.doc.createElement(GSXML.SERVICE_ELEM); 
     117        Element cb_service = this.desc_doc.createElement(GSXML.SERVICE_ELEM); 
    116118        cb_service.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_BROWSE); 
    117119        cb_service.setAttribute(GSXML.NAME_ATT, CLASSIFIER_SERVICE); 
     
    119121 
    120122        // metadata retrieval for the browsing   
    121         Element cbmr_service = this.doc.createElement(GSXML.SERVICE_ELEM); 
     123        Element cbmr_service = this.desc_doc.createElement(GSXML.SERVICE_ELEM); 
    122124        cbmr_service.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_RETRIEVE); 
    123125        cbmr_service.setAttribute(GSXML.NAME_ATT, CLASSIFIER_METADATA_SERVICE); 
     
    125127 
    126128        // the format info 
    127         Element cb_format_info = this.doc.createElement(GSXML.FORMAT_ELEM); 
     129        Element cb_format_info = this.desc_doc.createElement(GSXML.FORMAT_ELEM); 
    128130        boolean format_found = false; 
    129131 
     
    132134        if (def_format != null) 
    133135        { 
    134             cb_format_info.appendChild(GSXML.duplicateWithNewName(this.doc, def_format, GSXML.DEFAULT_ELEM, true)); 
     136            cb_format_info.appendChild(GSXML.duplicateWithNewName(this.desc_doc, def_format, GSXML.DEFAULT_ELEM, true)); 
    135137            format_found = true; 
    136138        } 
     
    142144            Element cl = (Element) classifiers.item(i); 
    143145 
    144             Element new_cl = (Element) this.doc.importNode(cl, false); // just import this node, not the children 
     146            Element new_cl = (Element) this.desc_doc.importNode(cl, false); // just import this node, not the children 
    145147 
    146148            // get the format info out, and put inside a classifier element 
     
    153155                for (int j = 0; j < elems.getLength(); j++) 
    154156                { 
    155                     format_cl.appendChild(this.doc.importNode(elems.item(j), true)); 
     157                    format_cl.appendChild(this.desc_doc.importNode(elems.item(j), true)); 
    156158                } 
    157159                cb_format_info.appendChild(format_cl); 
     
    184186 
    185187        // Base line for document (might be overriden by sub-classes) 
    186         gs_doc = new BasicDocument(this.doc, this.default_document_type); 
     188        gs_doc = new BasicDocument(this.default_document_type); 
    187189 
    188190        return true; 
    189191    } 
    190192 
    191     protected Element getServiceDescription(String service_id, String lang, String subset) 
     193  protected Element getServiceDescription(Document doc, String service_id, String lang, String subset) 
    192194    { 
    193195 
     
    202204            } 
    203205 
    204             Element cb_service = this.doc.createElement(GSXML.SERVICE_ELEM); 
     206            Element cb_service = doc.createElement(GSXML.SERVICE_ELEM); 
    205207            cb_service.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_BROWSE); 
    206208            cb_service.setAttribute(GSXML.NAME_ATT, CLASSIFIER_SERVICE); 
    207             cb_service.appendChild(GSXML.createDisplayTextElement(this.doc, GSXML.DISPLAY_TEXT_NAME, getTextString(CLASSIFIER_SERVICE + ".name", lang))); 
    208             cb_service.appendChild(GSXML.createDisplayTextElement(this.doc, GSXML.DISPLAY_TEXT_DESCRIPTION, getTextString(CLASSIFIER_SERVICE + ".description", lang))); 
    209  
    210             Element cl_list = this.doc.createElement(GSXML.CLASSIFIER_ELEM + GSXML.LIST_MODIFIER); 
     209            cb_service.appendChild(GSXML.createDisplayTextElement(doc, GSXML.DISPLAY_TEXT_NAME, getTextString(CLASSIFIER_SERVICE + ".name", lang))); 
     210            cb_service.appendChild(GSXML.createDisplayTextElement(doc, GSXML.DISPLAY_TEXT_DESCRIPTION, getTextString(CLASSIFIER_SERVICE + ".description", lang))); 
     211 
     212            Element cl_list = doc.createElement(GSXML.CLASSIFIER_ELEM + GSXML.LIST_MODIFIER); 
    211213            cb_service.appendChild(cl_list); 
    212214            NodeList classifiers = class_list.getElementsByTagName(GSXML.CLASSIFIER_ELEM); 
     
    214216            { 
    215217                Element cl = (Element) classifiers.item(i); 
    216                 Element new_cl = (Element) this.doc.importNode(cl, false); // just import this node, not the children 
     218                Element new_cl = (Element) doc.importNode(cl, false); // just import this node, not the children 
    217219 
    218220                //String content = cl.getAttribute(GSXML.CLASSIFIER_CONTENT_ATT); 
     
    236238                } 
    237239 
    238                 Element cl_name = GSXML.createDisplayTextElement(this.doc, GSXML.DISPLAY_TEXT_NAME, text); 
     240                Element cl_name = GSXML.createDisplayTextElement(doc, GSXML.DISPLAY_TEXT_NAME, text); 
    239241                new_cl.appendChild(cl_name); 
    240242 
     
    248250                String[] array = { meta_name }; 
    249251                String description = getTextString("ClassifierBrowse.classifier_help", lang, array); 
    250                 Element cl_desc = GSXML.createDisplayTextElement(this.doc, GSXML.DISPLAY_TEXT_DESCRIPTION, description); 
     252                Element cl_desc = GSXML.createDisplayTextElement(doc, GSXML.DISPLAY_TEXT_DESCRIPTION, description); 
    251253                new_cl.appendChild(cl_desc); 
    252254 
     
    260262        { 
    261263 
    262             Element cbmr_service = this.doc.createElement(GSXML.SERVICE_ELEM); 
     264            Element cbmr_service = doc.createElement(GSXML.SERVICE_ELEM); 
    263265            cbmr_service.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_RETRIEVE); 
    264266            cbmr_service.setAttribute(GSXML.NAME_ATT, CLASSIFIER_METADATA_SERVICE); 
     
    348350 
    349351        // Create a new (empty) result message 
    350         Element result = this.doc.createElement(GSXML.RESPONSE_ELEM); 
     352      Document result_doc = XMLConverter.newDOM(); 
     353        Element result = result_doc.createElement(GSXML.RESPONSE_ELEM); 
    351354        result.setAttribute(GSXML.FROM_ATT, CLASSIFIER_SERVICE); 
    352355        result.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_PROCESS); 
     
    424427 
    425428        // the node list to hold the results 
    426         Element node_list = this.doc.createElement(GSXML.CLASS_NODE_ELEM + GSXML.LIST_MODIFIER); 
     429        Element node_list = result_doc.createElement(GSXML.CLASS_NODE_ELEM + GSXML.LIST_MODIFIER); 
    427430        result.appendChild(node_list); 
    428431 
     
    432435        { 
    433436            // Add the document to the list 
    434             Element node = this.doc.createElement(GSXML.CLASS_NODE_ELEM); 
     437            Element node = result_doc.createElement(GSXML.CLASS_NODE_ELEM); 
    435438            node_list.appendChild(node); 
    436439 
     
    450453            if (want_info) 
    451454            { 
    452                 Element node_info_elem = this.doc.createElement("nodeStructureInfo"); 
     455                Element node_info_elem = result_doc.createElement("nodeStructureInfo"); 
    453456                node.appendChild(node_info_elem); 
    454457 
     
    459462                    if (info_value != null) 
    460463                    { 
    461                         Element info_elem = this.doc.createElement("info"); 
     464                        Element info_elem = result_doc.createElement("info"); 
    462465                        info_elem.setAttribute(GSXML.NAME_ATT, info_type); 
    463466                        info_elem.setAttribute(GSXML.VALUE_ATT, info_value); 
     
    470473            { 
    471474                // all structure info goes into a nodeStructure elem 
    472                 Element structure_elem = this.doc.createElement(GSXML.NODE_STRUCTURE_ELEM); 
     475                Element structure_elem = result_doc.createElement(GSXML.NODE_STRUCTURE_ELEM); 
    473476                node.appendChild(structure_elem); 
    474477 
     
    476479                { 
    477480                    String root_id = getRootId(node_id); 
    478                     Element root_node = createClassifierNode(root_id); //, true, false); 
     481                    Element root_node = createClassifierNode(result_doc, root_id); //, true, false); 
    479482                    addDescendants(root_node, root_id, true); 
    480483                    structure_elem.appendChild(root_node); 
     
    483486 
    484487                // Add the requested structure information 
    485                 Element base_node = createClassifierNode(node_id); //, false, false); 
     488                Element base_node = createClassifierNode(result_doc, node_id); //, false, false); 
    486489 
    487490                //Ancestors: continually add parent nodes until the root is reached 
     
    496499                        if (parent_id == null) 
    497500                            break; // no parent 
    498                         Element parent_node = createClassifierNode(parent_id); 
     501                        Element parent_node = createClassifierNode(result_doc, parent_id); 
    499502                        parent_node.appendChild(top_node); 
    500503                        current_id = parent_id;//.getAttribute(GSXML.NODE_ID_ATT); 
     
    508511                    if (parent_id != null) 
    509512                    { 
    510                         Element parent_node = createClassifierNode(parent_id); 
     513                      Element parent_node = createClassifierNode(result_doc, parent_id); 
    511514                        parent_node.appendChild(base_node); 
    512515                        top_node = parent_node; 
     
    567570 
    568571        // Create a new (empty) result message 
    569         Element result = this.doc.createElement(GSXML.RESPONSE_ELEM); 
     572      Document result_doc = XMLConverter.newDOM(); 
     573        Element result = result_doc.createElement(GSXML.RESPONSE_ELEM); 
    570574 
    571575        String lang = request.getAttribute(GSXML.LANG_ATT); 
     
    602606        } 
    603607 
    604         Element node_list = this.doc.createElement(GSXML.CLASS_NODE_ELEM + GSXML.LIST_MODIFIER); 
     608        Element node_list = result_doc.createElement(GSXML.CLASS_NODE_ELEM + GSXML.LIST_MODIFIER); 
    605609        result.appendChild(node_list); 
    606610 
     
    620624 
    621625            // Add the document to the results list 
    622             Element new_node = (Element) this.doc.importNode(request_node, false); 
     626            Element new_node = (Element) result_doc.importNode(request_node, false); 
    623627            node_list.appendChild(new_node); 
    624628 
     
    632636            } 
    633637 
    634             Element metadata_list = getMetadataList(node_id, all_metadata, metadata_names_list); 
     638            Element metadata_list = getMetadataList(result_doc, node_id, all_metadata, metadata_names_list); 
    635639            new_node.appendChild(metadata_list); 
    636640        } 
     
    640644 
    641645    /** Creates a classifier node */ 
    642     protected Element createClassifierNode(String node_id) 
    643     { 
    644         Element node = this.doc.createElement(GSXML.CLASS_NODE_ELEM); 
     646  protected Element createClassifierNode(Document doc, String node_id) 
     647    { 
     648        Element node = doc.createElement(GSXML.CLASS_NODE_ELEM); 
    645649        node.setAttribute(GSXML.NODE_ID_ATT, node_id); 
    646650        node.setAttribute(GSXML.CHILD_TYPE_ATT, getChildType(node_id)); 
     
    652656     * <docNode nodeId='xxx' nodeType='leaf' docType='hierarchy'/> 
    653657     */ 
    654     protected Element createDocNode(String node_id) 
    655     { 
    656       return this.gs_doc.createDocNode(node_id); 
     658  protected Element createDocNode(Document doc, String node_id) 
     659    { 
     660      return this.gs_doc.createDocNode(doc, node_id); 
    657661    } 
    658662 
     
    675679        if (child_ids == null) 
    676680            return; 
     681        Document doc = node.getOwnerDocument(); 
    677682        for (int i = 0; i < child_ids.size(); i++) 
    678683        { 
     
    681686            if (isDocumentId(child_id)) 
    682687            { 
    683                 child_elem = createDocNode(child_id); 
     688              child_elem = createDocNode(doc, child_id); 
    684689            } 
    685690            else 
    686691            { 
    687                 child_elem = createClassifierNode(child_id); 
     692              child_elem = createClassifierNode(doc, child_id); 
    688693            } 
    689694            node.appendChild(child_elem); 
     
    784789     * returns all available metadata, otherwise just returns requested metadata 
    785790     */ 
    786     abstract protected Element getMetadataList(String node_id, boolean all_metadata, ArrayList<String> metadata_names); 
     791  abstract protected Element getMetadataList(Document doc, String node_id, boolean all_metadata, ArrayList<String> metadata_names); 
    787792 
    788793    /** 
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/AbstractDocumentRetrieve.java

    r26198 r28966  
    3131import org.greenstone.gsdl3.util.OID; 
    3232import org.greenstone.gsdl3.util.GSConstants; 
     33import org.greenstone.gsdl3.util.XMLConverter; 
    3334 
    3435// XML classes 
     
    104105        if (does_structure) 
    105106        { 
    106             Element dsr_service = this.doc.createElement(GSXML.SERVICE_ELEM); 
     107            Element dsr_service = this.desc_doc.createElement(GSXML.SERVICE_ELEM); 
    107108            dsr_service.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_RETRIEVE); 
    108109            dsr_service.setAttribute(GSXML.NAME_ATT, DOCUMENT_STRUCTURE_RETRIEVE_SERVICE); 
     
    112113        if (does_metadata) 
    113114        { 
    114             Element dmr_service = this.doc.createElement(GSXML.SERVICE_ELEM); 
     115            Element dmr_service = this.desc_doc.createElement(GSXML.SERVICE_ELEM); 
    115116            dmr_service.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_RETRIEVE); 
    116117            dmr_service.setAttribute(GSXML.NAME_ATT, DOCUMENT_METADATA_RETRIEVE_SERVICE); 
     
    120121        if (does_content) 
    121122        { 
    122             Element dcr_service = this.doc.createElement(GSXML.SERVICE_ELEM); 
     123            Element dcr_service = this.desc_doc.createElement(GSXML.SERVICE_ELEM); 
    123124            dcr_service.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_RETRIEVE); 
    124125            dcr_service.setAttribute(GSXML.NAME_ATT, DOCUMENT_CONTENT_RETRIEVE_SERVICE); 
     
    131132        if (display_format != null) 
    132133        { 
    133             this.format_info_map.put(DOCUMENT_CONTENT_RETRIEVE_SERVICE, this.doc.importNode(display_format, true)); 
     134            this.format_info_map.put(DOCUMENT_CONTENT_RETRIEVE_SERVICE, this.desc_doc.importNode(display_format, true)); 
    134135            // should we keep a copy? 
    135136            // check for docType option. 
     
    171172 
    172173        // Base line for document (might be overriden by sub-classes) 
    173         gs_doc = new BasicDocument(this.doc, this.default_document_type); 
     174        gs_doc = new BasicDocument(this.default_document_type); 
    174175 
    175176        return true; 
    176177    } 
    177178 
    178     protected Element getServiceDescription(String service_id, String lang, String subset) 
     179  protected Element getServiceDescription(Document doc, String service_id, String lang, String subset) 
    179180    { 
    180181 
    181182        // these ones are probably never called, but put them here just in case 
    182         Element service_elem = this.doc.createElement(GSXML.SERVICE_ELEM); 
     183        Element service_elem = doc.createElement(GSXML.SERVICE_ELEM); 
    183184        service_elem.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_RETRIEVE); 
    184185        service_elem.setAttribute(GSXML.NAME_ATT, service_id); 
     
    190191 
    191192        // Create a new (empty) result message 
    192         Element result = this.doc.createElement(GSXML.RESPONSE_ELEM); 
     193      Document result_doc = XMLConverter.newDOM(); 
     194        Element result = result_doc.createElement(GSXML.RESPONSE_ELEM); 
    193195        String lang = request.getAttribute(GSXML.LANG_ATT); 
    194196        result.setAttribute(GSXML.FROM_ATT, DOCUMENT_METADATA_RETRIEVE_SERVICE); 
     
    204206        if (param_list == null) 
    205207        { 
    206             GSXML.addError(this.doc, result, "DocumentMetadataRetrieve: missing " + GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER, GSXML.ERROR_TYPE_SYNTAX); 
     208            GSXML.addError(result, "DocumentMetadataRetrieve: missing " + GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER, GSXML.ERROR_TYPE_SYNTAX); 
    207209            return result; 
    208210        } 
     
    232234        if (!all_metadata && metadata_names_list.size() == 0) 
    233235        { 
    234             GSXML.addError(this.doc, result, "DocumentMetadataRetrieve: no metadata names found in the " + GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER, GSXML.ERROR_TYPE_SYNTAX); 
     236            GSXML.addError(result, "DocumentMetadataRetrieve: no metadata names found in the " + GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER, GSXML.ERROR_TYPE_SYNTAX); 
    235237            return result; 
    236238        } 
     
    240242        if (request_node_list == null) 
    241243        { 
    242             GSXML.addError(this.doc, result, "DocumentMetadataRetrieve: missing " + GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER, GSXML.ERROR_TYPE_SYNTAX); 
     244            GSXML.addError(result, "DocumentMetadataRetrieve: missing " + GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER, GSXML.ERROR_TYPE_SYNTAX); 
    243245            return result; 
    244246        } 
    245247 
    246248        // copy the request doc node list to the response 
    247         Element response_node_list = (Element) this.doc.importNode(request_node_list, true); 
     249        Element response_node_list = (Element) result_doc.importNode(request_node_list, true); 
    248250        result.appendChild(response_node_list); 
    249251 
    250252        // use the copied list so that we add the metadata into the copy 
    251253        // are we just adding metadata for the top level nodes? or can we accept a hierarchy here??? 
    252         NodeList request_nodes = GSXML.getChildrenByTagName(response_node_list, GSXML.DOC_NODE_ELEM); 
    253         if (request_nodes.getLength() == 0) 
    254         { 
    255             GSXML.addError(this.doc, result, "DocumentMetadataRetrieve: no " + GSXML.DOC_NODE_ELEM + " found in the " + GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER, GSXML.ERROR_TYPE_SYNTAX); 
     254        NodeList doc_nodes = GSXML.getChildrenByTagName(response_node_list, GSXML.DOC_NODE_ELEM); 
     255        if (doc_nodes.getLength() == 0) 
     256        { 
     257            GSXML.addError(result, "DocumentMetadataRetrieve: no " + GSXML.DOC_NODE_ELEM + " found in the " + GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER, GSXML.ERROR_TYPE_SYNTAX); 
    256258            return result; 
    257259        } 
    258260 
    259261        // Whew, now we have checked (almost) all the syntax of the request, now we can process it. 
    260         for (int i = 0; i < request_nodes.getLength(); i++) 
    261         { 
    262             Element request_node = (Element) request_nodes.item(i); 
    263             String node_id = request_node.getAttribute(GSXML.NODE_ID_ATT); 
     262        for (int i = 0; i < doc_nodes.getLength(); i++) 
     263        { 
     264            Element doc_node = (Element) doc_nodes.item(i); 
     265            String node_id = doc_node.getAttribute(GSXML.NODE_ID_ATT); 
    264266            boolean is_href_id = false; 
    265267            if (node_id.equals("")) 
    266268            { 
    267                 node_id = getGreenstoneIdFromHref(request_node); 
     269                node_id = getGreenstoneIdFromHref(doc_node); 
    268270                if (node_id == null) 
    269271                { 
    270272                    // **** TODO, is this good enough??? 
    271                     request_node.setAttribute("external_link", "true"); 
     273                    doc_node.setAttribute("external_link", "true"); 
    272274                    continue; 
    273275                } 
     
    287289            try 
    288290            { 
    289               Element metadata_list = getMetadataList(node_id, all_metadata, metadata_names_list, lang); 
     291              Element metadata_list = getMetadataList(result_doc, node_id, all_metadata, metadata_names_list, lang); 
    290292                if (metadata_list != null) 
    291293                { 
    292                     request_node.appendChild(metadata_list); 
     294                    doc_node.appendChild(metadata_list); 
    293295                } 
    294296            } 
    295297            catch (GSException e) 
    296298            { 
    297                 GSXML.addError(this.doc, result, e.getMessage(), e.getType()); 
     299                GSXML.addError(result, e.getMessage(), e.getType()); 
    298300                if (e.getType().equals(GSXML.ERROR_TYPE_SYSTEM)) 
    299301                { 
     
    312314 
    313315        // Create a new (empty) result message 
    314         Element result = this.doc.createElement(GSXML.RESPONSE_ELEM); 
     316      Document result_doc = XMLConverter.newDOM(); 
     317        Element result = result_doc.createElement(GSXML.RESPONSE_ELEM); 
    315318        result.setAttribute(GSXML.FROM_ATT, DOCUMENT_STRUCTURE_RETRIEVE_SERVICE); 
    316319        result.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_PROCESS); 
     
    328331        if (param_list == null) 
    329332        { 
    330             GSXML.addError(this.doc, result, "DocumentStructureRetrieve: missing " + GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER, GSXML.ERROR_TYPE_SYNTAX); 
     333            GSXML.addError(result, "DocumentStructureRetrieve: missing " + GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER, GSXML.ERROR_TYPE_SYNTAX); 
    331334            return result; 
    332335        } 
     
    336339        if (query_doc_list == null) 
    337340        { 
    338             GSXML.addError(this.doc, result, "DocumentStructureRetrieve: missing " + GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER, GSXML.ERROR_TYPE_SYNTAX); 
     341            GSXML.addError(result, "DocumentStructureRetrieve: missing " + GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER, GSXML.ERROR_TYPE_SYNTAX); 
    339342            return result; 
    340343        } 
    341344 
    342345        // copy the doc_list to the response 
    343         Element response_node_list = (Element) this.doc.importNode(query_doc_list, true); 
     346        Element response_node_list = (Element) result_doc.importNode(query_doc_list, true); 
    344347        result.appendChild(response_node_list); 
    345348 
     
    348351        if (node_list.getLength() == 0) 
    349352        { 
    350             GSXML.addError(this.doc, result, "DocumentStructureRetrieve: no " + GSXML.DOC_NODE_ELEM + " found in the " + GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER, GSXML.ERROR_TYPE_SYNTAX); 
     353            GSXML.addError(result, "DocumentStructureRetrieve: no " + GSXML.DOC_NODE_ELEM + " found in the " + GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER, GSXML.ERROR_TYPE_SYNTAX); 
    351354            return result; 
    352355        } 
     
    407410            want_children = false; 
    408411 
     412        // for each of the doc nodes, get the required info 
     413        // these nodes are part of result_doc - can use that to create Elements 
    409414        for (int i = 0; i < node_list.getLength(); i++) 
    410415        { 
    411             Element doc = (Element) node_list.item(i); 
    412  
    413             String doc_id = doc.getAttribute(GSXML.NODE_ID_ATT); 
     416            Element doc_node = (Element) node_list.item(i); 
     417 
     418            String doc_id = doc_node.getAttribute(GSXML.NODE_ID_ATT); 
    414419            boolean is_href_id = false; 
    415420            if (doc_id.equals("")) 
    416421            { 
    417                 doc_id = getGreenstoneIdFromHref(doc); 
     422                doc_id = getGreenstoneIdFromHref(doc_node); 
    418423                if (doc_id == null) 
    419424                { 
    420425                    // **** TODO, is this good enough??? 
    421                     doc.setAttribute("external_link", "true"); 
     426                    doc_node.setAttribute("external_link", "true"); 
    422427                    continue; 
    423428                } 
    424                 doc.setAttribute(GSXML.NODE_ID_ATT, doc_id); 
     429                doc_node.setAttribute(GSXML.NODE_ID_ATT, doc_id); 
    425430            } 
    426431 
     
    428433            { 
    429434                doc_id = translateId(doc_id); 
    430                 doc.setAttribute(GSXML.NODE_ID_ATT, doc_id); 
     435                doc_node.setAttribute(GSXML.NODE_ID_ATT, doc_id); 
    431436            } 
    432437 
     
    438443            if (want_info) 
    439444            { 
    440                 Element node_info_elem = this.doc.createElement("nodeStructureInfo"); 
    441                 doc.appendChild(node_info_elem); 
     445              Element node_info_elem = result_doc.createElement("nodeStructureInfo"); 
     446                doc_node.appendChild(node_info_elem); 
    442447 
    443448                for (int j = 0; j < info_types.size(); j++) 
     
    447452                    if (info_value != null) 
    448453                    { 
    449                         Element info_elem = this.doc.createElement("info"); 
     454                        Element info_elem = result_doc.createElement("info"); 
    450455                        info_elem.setAttribute(GSXML.NAME_ATT, info_type); 
    451456                        info_elem.setAttribute(GSXML.VALUE_ATT, info_value); 
     
    458463            { 
    459464                // all structure info goes into a nodeStructure elem 
    460                 Element structure_elem = this.doc.createElement(GSXML.NODE_STRUCTURE_ELEM); 
    461                 doc.appendChild(structure_elem); 
     465                Element structure_elem = result_doc.createElement(GSXML.NODE_STRUCTURE_ELEM); 
     466                doc_node.appendChild(structure_elem); 
    462467 
    463468                if (want_entire_structure) 
    464469                { 
    465470                    String root_id = getRootId(doc_id); 
    466                     Element root_node = createDocNode(root_id); //, true, false); 
     471                    Element root_node = createDocNode(result_doc, root_id); //, true, false); 
    467472                    addDescendants(root_node, root_id, true); 
    468473                    structure_elem.appendChild(root_node); 
     
    471476 
    472477                // Add the requested structure information 
    473                 Element base_node = createDocNode(doc_id); //, false, false); 
     478                Element base_node = createDocNode(result_doc, doc_id); //, false, false); 
    474479 
    475480                //Ancestors: continually add parent nodes until the root is reached 
     
    484489                        if (parent_id == null) 
    485490                            break; // no parent 
    486                         Element parent_node = createDocNode(parent_id); 
     491                        Element parent_node = createDocNode(result_doc, parent_id); 
    487492                        parent_node.appendChild(top_node); 
    488493                        current_id = parent_id;//.getAttribute(GSXML.NODE_ID_ATT); 
     
    496501                    if (parent_id != null) 
    497502                    { 
    498                         Element parent_node = createDocNode(parent_id); 
     503                      Element parent_node = createDocNode(result_doc, parent_id); 
    499504                        parent_node.appendChild(base_node); 
    500505                        top_node = parent_node; 
     
    541546    { 
    542547        // Create a new (empty) result message 
    543         Element result = this.doc.createElement(GSXML.RESPONSE_ELEM); 
     548      Document result_doc = XMLConverter.newDOM(); 
     549        Element result = result_doc.createElement(GSXML.RESPONSE_ELEM); 
    544550        result.setAttribute(GSXML.FROM_ATT, DOCUMENT_CONTENT_RETRIEVE_SERVICE); 
    545551        result.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_PROCESS); 
     
    564570 
    565571        // copy the request doc node list to the response 
    566         Element response_node_list = (Element) this.doc.importNode(query_doc_list, true); 
     572        Element response_node_list = (Element) result_doc.importNode(query_doc_list, true); 
    567573        result.appendChild(response_node_list); 
    568574 
    569         NodeList request_nodes = GSXML.getChildrenByTagName(response_node_list, GSXML.DOC_NODE_ELEM); 
    570         if (request_nodes.getLength() == 0) 
    571         { 
    572             GSXML.addError(this.doc, result, "DocumentContentRetrieve: no " + GSXML.DOC_NODE_ELEM + " found in the " + GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER, GSXML.ERROR_TYPE_SYNTAX); 
    573             return result; 
    574         } 
    575  
    576         //Element doc_list = this.doc.createElement(GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER); 
     575        NodeList doc_nodes = GSXML.getChildrenByTagName(response_node_list, GSXML.DOC_NODE_ELEM); 
     576        if (doc_nodes.getLength() == 0) 
     577        { 
     578            GSXML.addError(result, "DocumentContentRetrieve: no " + GSXML.DOC_NODE_ELEM + " found in the " + GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER, GSXML.ERROR_TYPE_SYNTAX); 
     579            return result; 
     580        } 
     581 
     582        //Element doc_list = result_doc.createElement(GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER); 
    577583        //result.appendChild(doc_list); 
    578584 
     
    583589        //String[] is_externals = GSXML.getAttributeValuesFromList(query_doc_list, "externalURL"); 
    584590 
    585         for (int i = 0; i < request_nodes.getLength(); i++) 
    586         { 
    587             Element request_node = (Element) request_nodes.item(i); 
    588             String node_id = request_node.getAttribute(GSXML.NODE_ID_ATT); 
     591        for (int i = 0; i < doc_nodes.getLength(); i++) 
     592        { 
     593            Element doc_node = (Element) doc_nodes.item(i); 
     594            String node_id = doc_node.getAttribute(GSXML.NODE_ID_ATT); 
    589595             
    590596            if (node_id.equals("")) 
    591597            { 
    592                 node_id = getGreenstoneIdFromHref(request_node); 
     598                node_id = getGreenstoneIdFromHref(doc_node); 
    593599                if (node_id == null) 
    594600                { 
    595601                    // **** TODO, is this good enough??? 
    596                     request_node.setAttribute("external_link", "true"); 
     602                    doc_node.setAttribute("external_link", "true"); 
    597603                    continue; 
    598604                } 
    599                 request_node.setAttribute(GSXML.NODE_ID_ATT, node_id); 
     605                doc_node.setAttribute(GSXML.NODE_ID_ATT, node_id); 
    600606            } 
    601607 
     
    612618            try 
    613619            { 
    614                 Element node_content = getNodeContent(node_id, lang); 
     620              Element node_content = getNodeContent(result_doc, node_id, lang); 
    615621                if (node_content != null) 
    616622                { 
    617                     request_node.appendChild(node_content); 
     623                  doc_node.appendChild(node_content); 
    618624                } 
    619625            } 
    620626            catch (GSException e) 
    621627            { 
    622                 GSXML.addError(this.doc, result, e.getMessage()); 
     628                GSXML.addError(result, e.getMessage()); 
    623629                return result; 
    624630            } 
     
    631637     * <docNode nodeId='xxx' nodeType='leaf' docType='hierarchy'/> 
    632638     */ 
    633     protected Element createDocNode(String node_id) 
    634     { 
    635         return this.gs_doc.createDocNode(node_id); 
     639  protected Element createDocNode(Document doc, String node_id) 
     640    { 
     641      return this.gs_doc.createDocNode(doc, node_id); 
    636642    } 
    637643 
     
    759765     * <metadataList><metadata name="xxx">value</metadata></metadataList> 
    760766     */ 
    761   abstract protected Element getMetadataList(String doc_id, boolean all_metadata, ArrayList<String> metadata_names, String lang) throws GSException; 
     767  abstract protected Element getMetadataList(Document doc, String doc_id, boolean all_metadata, ArrayList<String> metadata_names, String lang) throws GSException; 
    762768 
    763769    /** 
     
    765771     * <nodeContent>text content or other elements</nodeContent> can return 
    766772     */ 
    767     abstract protected Element getNodeContent(String doc_id, String lang) throws GSException; 
     773  abstract protected Element getNodeContent(Document doc, String doc_id, String lang) throws GSException; 
    768774 
    769775    /** 
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/AbstractGS2DocumentRetrieve.java

    r26198 r28966  
    127127        } 
    128128 
    129         gs_doc_db = new BasicDocumentDatabase(this.doc, database_type, this.site_home, this.cluster_name, this.index_stem); 
     129        gs_doc_db = new BasicDocumentDatabase(database_type, this.site_home, this.cluster_name, this.index_stem); 
    130130        if (!gs_doc_db.isValid()) 
    131131        { 
     
    174174     * name="xxx">value</metadata></metadataList> 
    175175     */ 
    176   protected Element getMetadataList(String node_id, boolean all_metadata, ArrayList<String> metadata_names, String lang) throws GSException 
    177     { 
    178         Element metadata_list = this.doc.createElement(GSXML.METADATA_ELEM + GSXML.LIST_MODIFIER); 
     176  protected Element getMetadataList(Document doc, String node_id, boolean all_metadata, ArrayList<String> metadata_names, String lang) throws GSException 
     177    { 
     178        Element metadata_list = doc.createElement(GSXML.METADATA_ELEM + GSXML.LIST_MODIFIER); 
    179179        DBInfo info = this.coll_db.getInfo(node_id); 
    180180        if (info == null) 
     
    195195                for (int i = 0; i < values.size(); i++) 
    196196                { 
    197                   GSXML.addMetadata(this.doc, metadata_list, key, this.macro_resolver.resolve(values.elementAt(i), lang, MacroResolver.SCOPE_META, node_id)); 
     197                  GSXML.addMetadata(metadata_list, key, this.macro_resolver.resolve(values.elementAt(i), lang, MacroResolver.SCOPE_META, node_id)); 
    198198                } 
    199199            } 
     
    213213            { 
    214214              // some of these may be parent/ancestor. does resolve need a different id??? 
    215               GSXML.addMetadata(this.doc, metadata_list, meta_name,  this.macro_resolver.resolve(values.elementAt(j), lang, MacroResolver.SCOPE_META, node_id)); 
     215              GSXML.addMetadata(metadata_list, meta_name,  this.macro_resolver.resolve(values.elementAt(j), lang, MacroResolver.SCOPE_META, node_id)); 
    216216            } 
    217217            } 
     
    295295     * <nodeContent>text content or other elements</nodeContent> 
    296296     */ 
    297     abstract protected Element getNodeContent(String doc_id, String lang) throws GSException; 
     297  abstract protected Element getNodeContent(Document doc, String doc_id, String lang) throws GSException; 
    298298 
    299299 
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/AbstractGS2FieldSearch.java

    r28181 r28966  
    2626import org.greenstone.gsdl3.util.FacetWrapper; 
    2727import org.greenstone.gsdl3.util.GSXML; 
     28import org.greenstone.gsdl3.util.XMLConverter; 
     29 
    2830import org.w3c.dom.Document; 
    2931import org.w3c.dom.Element; 
     
    226228        { 
    227229            // set up short_service_info_ - for now just has id and type - name will be added in on the fly 
    228             Element fq_service = this.doc.createElement(GSXML.SERVICE_ELEM); 
     230            Element fq_service = this.desc_doc.createElement(GSXML.SERVICE_ELEM); 
    229231            fq_service.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_QUERY); 
    230232            fq_service.setAttribute(GSXML.NAME_ATT, FIELD_QUERY_SERVICE); 
     
    239241        if (this.advanced_form_search) 
    240242        { 
    241             Element afq_service = this.doc.createElement(GSXML.SERVICE_ELEM); 
     243            Element afq_service = this.desc_doc.createElement(GSXML.SERVICE_ELEM); 
    242244            afq_service.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_QUERY); 
    243245            afq_service.setAttribute(GSXML.NAME_ATT, ADVANCED_FIELD_QUERY_SERVICE); 
     
    252254        if (this.raw_search) 
    253255        { 
    254             Element rq_service = this.doc.createElement(GSXML.SERVICE_ELEM); 
     256            Element rq_service = this.desc_doc.createElement(GSXML.SERVICE_ELEM); 
    255257            rq_service.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_QUERY); 
    256258            rq_service.setAttribute(GSXML.NAME_ATT, RAW_QUERY_SERVICE); 
     
    299301    } 
    300302  } 
    301     protected Element getServiceDescription(String service_id, String lang, String subset) 
     303  protected Element getServiceDescription(Document doc, String service_id, String lang, String subset) 
    302304    { 
    303305        // should we check that the service is actually on offer? presumably we wont get asked for services that we haven't advertised previously. 
     
    305307        if (!service_id.equals(FIELD_QUERY_SERVICE) && !service_id.equals(ADVANCED_FIELD_QUERY_SERVICE) && !service_id.equals(RAW_QUERY_SERVICE)) 
    306308        { 
    307             return super.getServiceDescription(service_id, lang, subset); 
    308         } 
    309  
    310         Element service = this.doc.createElement(GSXML.SERVICE_ELEM); 
     309          return super.getServiceDescription(doc, service_id, lang, subset); 
     310        } 
     311 
     312        Element service = doc.createElement(GSXML.SERVICE_ELEM); 
    311313        service.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_QUERY); 
    312314        service.setAttribute(GSXML.NAME_ATT, service_id); 
    313315        if (subset == null || subset.equals(GSXML.DISPLAY_TEXT_ELEM + GSXML.LIST_MODIFIER)) 
    314316        { 
    315             service.appendChild(GSXML.createDisplayTextElement(this.doc, GSXML.DISPLAY_TEXT_NAME, getTextString(service_id + ".name", lang))); 
    316             service.appendChild(GSXML.createDisplayTextElement(this.doc, GSXML.DISPLAY_TEXT_SUBMIT, getTextString(service_id + ".submit", lang))); 
    317             service.appendChild(GSXML.createDisplayTextElement(this.doc, GSXML.DISPLAY_TEXT_DESCRIPTION, getTextString(service_id + ".description", lang))); 
     317            service.appendChild(GSXML.createDisplayTextElement(doc, GSXML.DISPLAY_TEXT_NAME, getTextString(service_id + ".name", lang))); 
     318            service.appendChild(GSXML.createDisplayTextElement(doc, GSXML.DISPLAY_TEXT_SUBMIT, getTextString(service_id + ".submit", lang))); 
     319            service.appendChild(GSXML.createDisplayTextElement(doc, GSXML.DISPLAY_TEXT_DESCRIPTION, getTextString(service_id + ".description", lang))); 
    318320 
    319321        } 
    320322        if (subset == null || subset.equals(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER)) 
    321323        { 
    322             Element param_list = this.doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER); 
     324            Element param_list = doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER); 
    323325            service.appendChild(param_list); 
    324326            if (service_id.equals(FIELD_QUERY_SERVICE)) 
     
    346348                Element multiparam = null; 
    347349                Element param = null; 
    348                 multiparam = GSXML.createParameterDescription(this.doc, SIMPLE_FIELD_PARAM, "", GSXML.PARAM_TYPE_MULTI, null, null, null); 
     350                multiparam = GSXML.createParameterDescription(doc, SIMPLE_FIELD_PARAM, "", GSXML.PARAM_TYPE_MULTI, null, null, null); 
    349351                multiparam.setAttribute("occurs", "4"); 
    350352                param_list.appendChild(multiparam); 
     
    376378                Element param = null; 
    377379 
    378                 multiparam = GSXML.createParameterDescription(this.doc, ADVANCED_FIELD_PARAM, "", GSXML.PARAM_TYPE_MULTI, null, null, null); 
     380                multiparam = GSXML.createParameterDescription(doc, ADVANCED_FIELD_PARAM, "", GSXML.PARAM_TYPE_MULTI, null, null, null); 
    379381                multiparam.setAttribute("occurs", "4"); 
    380382                param_list.appendChild(multiparam); 
     
    431433    protected void createParameter(String name, Element param_list, String lang) 
    432434    { 
     435      Document doc = param_list.getOwnerDocument(); 
    433436        Element param = null; 
    434437        String param_default = paramDefaults.get(name); 
     
    441444            { 
    442445                // the first one is the default 
    443                 //param = GSXML.createParameterDescription2(this.doc, LEVEL_PARAM, getTextString("param."+LEVEL_PARAM, lang), GSXML.PARAM_TYPE_ENUM_SINGLE, (String)level_ids.get(0), level_ids, level_names); 
    444                 param = GSXML.createParameterDescription2(this.doc, LEVEL_PARAM, getTextString("param." + LEVEL_PARAM, lang), GSXML.PARAM_TYPE_ENUM_SINGLE, this.default_level, level_ids, level_names); 
     446                //param = GSXML.createParameterDescription2(doc, LEVEL_PARAM, getTextString("param."+LEVEL_PARAM, lang), GSXML.PARAM_TYPE_ENUM_SINGLE, (String)level_ids.get(0), level_ids, level_names); 
     447                param = GSXML.createParameterDescription2(doc, LEVEL_PARAM, getTextString("param." + LEVEL_PARAM, lang), GSXML.PARAM_TYPE_ENUM_SINGLE, this.default_level, level_ids, level_names); 
    445448            } 
    446449            else 
    447450            { 
    448451                // we need to set the level, but hidden, in case there is an invalid level saved 
    449                 //param = GSXML.createParameterDescription(this.doc, LEVEL_PARAM, "", GSXML.PARAM_TYPE_INVISIBLE, (String)level_ids.get(0), null, null); 
    450                 param = GSXML.createParameterDescription(this.doc, LEVEL_PARAM, "", GSXML.PARAM_TYPE_INVISIBLE, this.default_level, null, null); 
     452                //param = GSXML.createParameterDescription(doc, LEVEL_PARAM, "", GSXML.PARAM_TYPE_INVISIBLE, (String)level_ids.get(0), null, null); 
     453                param = GSXML.createParameterDescription(doc, LEVEL_PARAM, "", GSXML.PARAM_TYPE_INVISIBLE, this.default_level, null, null); 
    451454            } 
    452455        } 
     
    456459            String[] vals1_texts = { getTextString("param." + RANK_PARAM + "." + RANK_PARAM_RANK, lang), getTextString("param." + RANK_PARAM + "." + RANK_PARAM_NONE, lang) }; 
    457460 
    458             param = GSXML.createParameterDescription(this.doc, RANK_PARAM, getTextString("param." + RANK_PARAM, lang), GSXML.PARAM_TYPE_ENUM_SINGLE, param_default, vals1, vals1_texts); 
     461            param = GSXML.createParameterDescription(doc, RANK_PARAM, getTextString("param." + RANK_PARAM, lang), GSXML.PARAM_TYPE_ENUM_SINGLE, param_default, vals1, vals1_texts); 
    459462 
    460463        } 
    461464        else if (name.equals(FIELD_QUERY_PARAM)) 
    462465        { 
    463             param = GSXML.createParameterDescription(this.doc, FIELD_QUERY_PARAM, getTextString("param." + FIELD_QUERY_PARAM, lang), GSXML.PARAM_TYPE_STRING, null, null, null); 
     466            param = GSXML.createParameterDescription(doc, FIELD_QUERY_PARAM, getTextString("param." + FIELD_QUERY_PARAM, lang), GSXML.PARAM_TYPE_STRING, null, null, null); 
    464467 
    465468        } 
     
    468471            String[] bool_ops = { "0", "1" }; 
    469472            String[] bool_texts = { getTextString("param.boolean.off", lang, "AbstractTextSearch"), getTextString("param.boolean.on", lang, "AbstractTextSearch") }; 
    470             param = GSXML.createParameterDescription(this.doc, name, getTextString("param." + name, lang), GSXML.PARAM_TYPE_BOOLEAN, param_default, bool_ops, bool_texts); 
     473            param = GSXML.createParameterDescription(doc, name, getTextString("param." + name, lang), GSXML.PARAM_TYPE_BOOLEAN, param_default, bool_ops, bool_texts); 
    471474 
    472475        } 
     
    481484            // org.greenstone.gsdl3.service.AbstractGS2FieldSearch.createParameter(AbstractGS2FieldSearch.java:362) 
    482485            // Changed from: 
    483             // param = GSXML.createParameterDescription2(this.doc, name, getTextString("param."+name, lang), GSXML.PARAM_TYPE_ENUM_SINGLE, (String)fields.get(0), fields, field_names ); 
     486            // param = GSXML.createParameterDescription2(doc, name, getTextString("param."+name, lang), GSXML.PARAM_TYPE_ENUM_SINGLE, (String)fields.get(0), fields, field_names ); 
    484487            String default_value = (fields.size() > 0) ? fields.get(0) : null; 
    485488            // don't want to access element 0 if fields.size()==0, and 
    486489            // GSXML.createParameterDescription2 checks for default_value==null condition 
    487             param = GSXML.createParameterDescription2(this.doc, name, getTextString("param." + name, lang), GSXML.PARAM_TYPE_ENUM_SINGLE, default_value, fields, field_names); 
     490            param = GSXML.createParameterDescription2(doc, name, getTextString("param." + name, lang), GSXML.PARAM_TYPE_ENUM_SINGLE, default_value, fields, field_names); 
    488491 
    489492        } 
     
    494497            String[] val_texts = { getTextString("param." + FIELD_COMBINE_PARAM + "." + FIELD_COMBINE_PARAM_AND, lang), getTextString("param." + FIELD_COMBINE_PARAM + "." + FIELD_COMBINE_PARAM_OR, lang), getTextString("param." + FIELD_COMBINE_PARAM + "." + FIELD_COMBINE_PARAM_NOT, lang) }; 
    495498 
    496             param = GSXML.createParameterDescription(this.doc, FIELD_COMBINE_PARAM, "", GSXML.PARAM_TYPE_ENUM_SINGLE, param_default, vals, val_texts); 
     499            param = GSXML.createParameterDescription(doc, FIELD_COMBINE_PARAM, "", GSXML.PARAM_TYPE_ENUM_SINGLE, param_default, vals, val_texts); 
    497500            param.setAttribute(GSXML.PARAM_IGNORE_POS_ATT, "0"); 
    498501        } 
     
    596599 
    597600        // Create a new (empty) result message 
    598         Element result = this.doc.createElement(GSXML.RESPONSE_ELEM); 
     601        Document result_doc = XMLConverter.newDOM(); 
     602        Element result = result_doc.createElement(GSXML.RESPONSE_ELEM); 
    599603        result.setAttribute(GSXML.FROM_ATT, service_name); 
    600604        result.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_PROCESS); 
     
    652656        // Create a metadata list to store information about the query results 
    653657        // should we be using metadataList? or something else? 
    654         Element metadata_list = this.doc.createElement(GSXML.METADATA_ELEM + GSXML.LIST_MODIFIER); 
     658        Element metadata_list = result_doc.createElement(GSXML.METADATA_ELEM + GSXML.LIST_MODIFIER); 
    655659        result.appendChild(metadata_list); 
    656660 
     
    658662        long totalDocs = numDocsMatched(query_result); 
    659663 
    660         GSXML.addMetadata(this.doc, metadata_list, "numDocsMatched", "" + totalDocs); 
     664        GSXML.addMetadata(metadata_list, "numDocsMatched", "" + totalDocs); 
    661665 
    662666        // Create a document list to store the matching documents, and add them 
     
    675679            } 
    676680        } 
    677         GSXML.addMetadata(this.doc, metadata_list, "numDocsReturned", "" + docs_returned); 
     681        GSXML.addMetadata(metadata_list, "numDocsReturned", "" + docs_returned); 
    678682 
    679683        // add a metadata item to specify what actual query was done - eg if stuff was stripped out etc. and then we can use the query later, cos we don't know which parameter was the query 
    680         GSXML.addMetadata(this.doc, metadata_list, "query", query); 
     684        GSXML.addMetadata(metadata_list, "query", query); 
    681685        if (docs.length > 0) 
    682686        { 
    683             Element document_list = this.doc.createElement(GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER); 
     687            Element document_list = result_doc.createElement(GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER); 
    684688            result.appendChild(document_list); 
    685689            for (int d = 0; d < docs.length; d++) 
    686690            { 
    687691                String doc_id = internalNum2OID(docs[d]); 
    688                 Element doc_node = createDocNode(doc_id, doc_ranks[d]); 
     692                Element doc_node = createDocNode(result_doc, doc_id, doc_ranks[d]); 
    689693                document_list.appendChild(doc_node); 
    690694            } 
     
    692696 
    693697        // Create a term list to store the term information, and add it 
    694         Element term_list = this.doc.createElement(GSXML.TERM_ELEM + GSXML.LIST_MODIFIER); 
     698        Element term_list = result_doc.createElement(GSXML.TERM_ELEM + GSXML.LIST_MODIFIER); 
    695699        result.appendChild(term_list); 
    696700        addTermInfo(term_list, params, query_result); 
     
    701705            if(facets != null) 
    702706            { 
    703                 Element facet_list = this.doc.createElement(GSXML.FACET_ELEM + GSXML.LIST_MODIFIER); 
     707                Element facet_list = result_doc.createElement(GSXML.FACET_ELEM + GSXML.LIST_MODIFIER); 
    704708                result.appendChild(facet_list); 
    705709 
    706710                for(FacetWrapper currentFacet : facets) 
    707711                { 
    708                     Element facet_elem = this.doc.createElement(GSXML.FACET_ELEM); 
     712                    Element facet_elem = result_doc.createElement(GSXML.FACET_ELEM); 
    709713                    facet_elem.setAttribute(GSXML.NAME_ATT, currentFacet.getName()); 
    710714                    facet_list.appendChild(facet_elem); 
     
    717721                        if(countValue > 0) 
    718722                        { 
    719                             Element count_elem = this.doc.createElement(GSXML.COUNT_ELEM); 
     723                            Element count_elem = result_doc.createElement(GSXML.COUNT_ELEM); 
    720724                            count_elem.setAttribute(GSXML.NAME_ATT, countName); 
    721725                            count_elem.setTextContent("" + countValue); 
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/AbstractGS2TextSearch.java

    r28181 r28966  
    108108 
    109109        // replaces default AbstractSearch version with one tied to database 
    110         gs_doc_db = new BasicDocumentDatabase(this.doc, database_type, this.site_home, this.cluster_name, this.index_stem); 
     110        gs_doc_db = new BasicDocumentDatabase(database_type, this.site_home, this.cluster_name, this.index_stem); 
    111111        if (!gs_doc_db.isValid()) 
    112112        { 
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/AbstractSearch.java

    r28181 r28966  
    2828import org.greenstone.gsdl3.util.GSPath; 
    2929import org.greenstone.gsdl3.util.GSXML; 
     30import org.w3c.dom.Document; 
    3031import org.w3c.dom.Element; 
    3132import org.w3c.dom.NodeList; 
     
    106107        //    will be added in if the list is requested. 
    107108 
    108         Element tq_service = this.doc.createElement(GSXML.SERVICE_ELEM); 
     109        Element tq_service = this.desc_doc.createElement(GSXML.SERVICE_ELEM); 
    109110        tq_service.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_QUERY); 
    110111        tq_service.setAttribute(GSXML.NAME_ATT, QUERY_SERVICE); 
     
    142143        if (format != null) 
    143144        { 
    144             this.format_info_map.put(QUERY_SERVICE, this.doc.importNode(format, true)); 
     145            this.format_info_map.put(QUERY_SERVICE, this.desc_doc.importNode(format, true)); 
    145146        } 
    146147 
     
    163164 
    164165        // Base line for document (might be overriden by sub-classes) 
    165         gs_doc = new BasicDocument(this.doc, this.default_document_type); 
     166        gs_doc = new BasicDocument(this.default_document_type); 
    166167 
    167168        return true; 
     
    184185     * other services they need to provide their own descriptions 
    185186     */ 
    186     protected Element getServiceDescription(String service, String lang, String subset) 
     187  protected Element getServiceDescription(Document doc, String service, String lang, String subset) 
    187188    { 
    188189        if (!service.equals(QUERY_SERVICE)) 
     
    191192        } 
    192193 
    193         Element tq_service = this.doc.createElement(GSXML.SERVICE_ELEM); 
     194        Element tq_service = doc.createElement(GSXML.SERVICE_ELEM); 
    194195        tq_service.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_QUERY); 
    195196        tq_service.setAttribute(GSXML.NAME_ATT, QUERY_SERVICE); 
    196197        if (subset == null || subset.equals(GSXML.DISPLAY_TEXT_ELEM + GSXML.LIST_MODIFIER)) 
    197198        { 
    198             tq_service.appendChild(GSXML.createDisplayTextElement(this.doc, GSXML.DISPLAY_TEXT_NAME, getServiceName(QUERY_SERVICE, lang))); 
    199             tq_service.appendChild(GSXML.createDisplayTextElement(this.doc, GSXML.DISPLAY_TEXT_SUBMIT, getServiceSubmit(QUERY_SERVICE, lang))); 
    200             tq_service.appendChild(GSXML.createDisplayTextElement(this.doc, GSXML.DISPLAY_TEXT_DESCRIPTION, getServiceDescription(QUERY_SERVICE, lang))); 
     199            tq_service.appendChild(GSXML.createDisplayTextElement(doc, GSXML.DISPLAY_TEXT_NAME, getServiceName(QUERY_SERVICE, lang))); 
     200            tq_service.appendChild(GSXML.createDisplayTextElement(doc, GSXML.DISPLAY_TEXT_SUBMIT, getServiceSubmit(QUERY_SERVICE, lang))); 
     201            tq_service.appendChild(GSXML.createDisplayTextElement(doc, GSXML.DISPLAY_TEXT_DESCRIPTION, getServiceDescription(QUERY_SERVICE, lang))); 
    201202        } 
    202203        if (subset == null || subset.equals(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER)) 
    203204        { 
    204             Element param_list = this.doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER); 
     205            Element param_list = doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER); 
    205206            addCustomQueryParams(param_list, lang); 
    206207            addStandardQueryParams(param_list, lang); 
     
    282283    protected boolean createParameterChain(String name, Element param_list, String lang, String default_value) 
    283284    { 
     285      Document doc = param_list.getOwnerDocument(); 
    284286        Element param = null; 
    285287        String param_default = default_value; 
     
    290292        if (name.equals(QUERY_PARAM) || name.equals(RAW_PARAM)) 
    291293        { 
    292             param = GSXML.createParameterDescription(this.doc, name, getTextString("param." + name, lang), GSXML.PARAM_TYPE_STRING, param_default, null, null); 
     294            param = GSXML.createParameterDescription(doc, name, getTextString("param." + name, lang), GSXML.PARAM_TYPE_STRING, param_default, null, null); 
    293295            param_list.appendChild(param); 
    294296            return true; 
     
    309311                param_default = this.default_index; 
    310312            } 
    311             param = GSXML.createParameterDescription2(this.doc, INDEX_PARAM, getTextString("param." + INDEX_PARAM, lang), param_type, param_default, index_ids, index_names); 
     313            param = GSXML.createParameterDescription2(doc, INDEX_PARAM, getTextString("param." + INDEX_PARAM, lang), param_type, param_default, index_ids, index_names); 
    312314            param_list.appendChild(param); 
    313315            return true; 
     
    315317        else if (name.equals(MAXDOCS_PARAM)) 
    316318        { 
    317             param = GSXML.createParameterDescription(this.doc, name, getTextString("param." + name, lang), GSXML.PARAM_TYPE_INTEGER, param_default, null, null); 
     319            param = GSXML.createParameterDescription(doc, name, getTextString("param." + name, lang), GSXML.PARAM_TYPE_INTEGER, param_default, null, null); 
    318320            param_list.appendChild(param); 
    319321            return true; 
     
    321323        else if (name.equals(HITS_PER_PAGE_PARAM)) 
    322324        { 
    323             param = GSXML.createParameterDescription(this.doc, name, getTextString("param." + name, lang), GSXML.PARAM_TYPE_INTEGER, param_default, null, null); 
     325            param = GSXML.createParameterDescription(doc, name, getTextString("param." + name, lang), GSXML.PARAM_TYPE_INTEGER, param_default, null, null); 
    324326            param_list.appendChild(param); 
    325327            return true; 
     
    328330        { 
    329331            // start page - set to 1 for the search page 
    330             param = GSXML.createParameterDescription(this.doc, START_PAGE_PARAM, "", GSXML.PARAM_TYPE_INVISIBLE, param_default, null, null); 
     332            param = GSXML.createParameterDescription(doc, START_PAGE_PARAM, "", GSXML.PARAM_TYPE_INVISIBLE, param_default, null, null); 
    331333            param_list.appendChild(param); 
    332334            return true; 
     
    343345     * rank='0.23'/> 
    344346     */ 
    345     protected Element createDocNode(String node_id, String rank) 
    346     { 
    347         return this.gs_doc.createDocNode(node_id, rank); 
     347  protected Element createDocNode(Document doc, String node_id, String rank) 
     348    { 
     349      return this.gs_doc.createDocNode(doc, node_id, rank); 
    348350    } 
    349351 
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/AbstractTextSearch.java

    r28181 r28966  
    2424import org.apache.log4j.Logger; 
    2525import org.greenstone.gsdl3.util.GSXML; 
     26 
     27import org.w3c.dom.Document; 
    2628import org.w3c.dom.Element; 
    2729 
     
    9092    protected boolean createParameterChain(String name, Element param_list, String lang, String default_value) 
    9193    { 
     94      Document doc = param_list.getOwnerDocument(); 
    9295        Element param = null; 
    9396        String param_default = default_value; 
     
    120123                param_default = this.default_index_subcollection; 
    121124            } 
    122             param = GSXML.createParameterDescription2(this.doc, INDEX_SUBCOLLECTION_PARAM, getTextString("param." + INDEX_SUBCOLLECTION_PARAM, lang), param_type, param_default, index_sub_ids, index_sub_names); 
     125            param = GSXML.createParameterDescription2(doc, INDEX_SUBCOLLECTION_PARAM, getTextString("param." + INDEX_SUBCOLLECTION_PARAM, lang), param_type, param_default, index_sub_ids, index_sub_names); 
    123126            param_list.appendChild(param); 
    124127            return true; 
     
    141144                param_default = this.default_index_language; 
    142145            } 
    143             param = GSXML.createParameterDescription2(this.doc, INDEX_LANGUAGE_PARAM, getTextString("param." + INDEX_LANGUAGE_PARAM, lang), param_type, param_default, index_lang_ids, index_lang_names); 
     146            param = GSXML.createParameterDescription2(doc, INDEX_LANGUAGE_PARAM, getTextString("param." + INDEX_LANGUAGE_PARAM, lang), param_type, param_default, index_lang_ids, index_lang_names); 
    144147            param_list.appendChild(param); 
    145148            return true; 
     
    148151        String[] bool_ops = {"0", "1"}; 
    149152        String[] bool_texts = {getTextString("param.boolean.off", lang),getTextString("param.boolean.on", lang)};  
    150         param = GSXML.createParameterDescription(this.doc, name, getTextString("param."+name, lang), GSXML.PARAM_TYPE_BOOLEAN, param_default, bool_ops, bool_texts); 
     153        param = GSXML.createParameterDescription(doc, name, getTextString("param."+name, lang), GSXML.PARAM_TYPE_BOOLEAN, param_default, bool_ops, bool_texts); 
    151154        param_list.appendChild(param); 
    152155        return true; 
     
    155158        String[] vals = {MATCH_PARAM_SOME, MATCH_PARAM_ALL }; 
    156159        String[] val_texts = {getTextString("param."+MATCH_PARAM+"."+MATCH_PARAM_SOME, lang), getTextString("param."+MATCH_PARAM+"."+MATCH_PARAM_ALL, lang)};  
    157         param = GSXML.createParameterDescription(this.doc, MATCH_PARAM, getTextString("param."+MATCH_PARAM, lang), GSXML.PARAM_TYPE_ENUM_SINGLE, param_default, vals, val_texts); 
     160        param = GSXML.createParameterDescription(doc, MATCH_PARAM, getTextString("param."+MATCH_PARAM, lang), GSXML.PARAM_TYPE_ENUM_SINGLE, param_default, vals, val_texts); 
    158161        param_list.appendChild(param); 
    159162        return true; 
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/ArchiveIO.java

    r25635 r28966  
    2929import org.greenstone.gsdl3.util.SimpleCollectionDatabase; 
    3030import org.greenstone.gsdl3.util.UserContext; 
    31  
     31import org.greenstone.gsdl3.util.XMLConverter; 
     32 
     33import org.w3c.dom.Document; 
    3234import org.w3c.dom.Element; 
    3335import org.w3c.dom.NodeList; 
     
    7274        for (int i = 0; i < _services.length; i++) 
    7375        { 
    74             Element service = this.doc.createElement(GSXML.SERVICE_ELEM); 
     76            Element service = this.desc_doc.createElement(GSXML.SERVICE_ELEM); 
    7577            service.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_RETRIEVE); 
    7678            service.setAttribute(GSXML.NAME_ATT, _services[i]); 
     
    7880        } 
    7981         
    80         _GSDM = new GSDocumentModel(this.site_home, this.doc, this.router); 
     82        _GSDM = new GSDocumentModel(this.site_home, this.router); 
    8183 
    8284        return true; 
    8385    } 
    8486 
    85     protected Element getServiceDescription(String service_id, String lang, String subset) 
     87  protected Element getServiceDescription(Document doc, String service_id, String lang, String subset) 
    8688    { 
    8789        for (int i = 0; i < _services.length; i++) 
     
    8991            if (service_id.equals(_services[i])) 
    9092            { 
    91                 Element service_elem = this.doc.createElement(GSXML.SERVICE_ELEM); 
     93                Element service_elem = doc.createElement(GSXML.SERVICE_ELEM); 
    9294                service_elem.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_RETRIEVE); 
    9395                service_elem.setAttribute(GSXML.NAME_ATT, _services[i]); 
     
    106108    { 
    107109        // Create a new (empty) result message 
    108         Element result = this.doc.createElement(GSXML.RESPONSE_ELEM); 
     110      Document result_doc = XMLConverter.newDOM(); 
     111        Element result = result_doc.createElement(GSXML.RESPONSE_ELEM); 
    109112        result.setAttribute(GSXML.FROM_ATT, ARCHIVE_GET_DOCUMENT_FILE_PATH); 
    110113        result.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_PROCESS); 
     
    116119        if (param_list == null) 
    117120        { 
    118             GSXML.addError(this.doc, result, ARCHIVE_GET_DOCUMENT_FILE_PATH + ": Missing " + GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER, GSXML.ERROR_TYPE_SYNTAX); 
     121            GSXML.addError(result, ARCHIVE_GET_DOCUMENT_FILE_PATH + ": Missing " + GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER, GSXML.ERROR_TYPE_SYNTAX); 
    119122            return result; 
    120123        } 
     
    126129        String filePath = _GSDM.archiveGetDocumentFilePath(oid, collection, userContext); 
    127130         
    128         Element metadataList = this.doc.createElement(GSXML.METADATA_ELEM + GSXML.LIST_MODIFIER); 
    129         metadataList.appendChild(GSXML.createMetadataElement(this.doc, "docfilepath", filePath)); //TODO: Replace "docfilepath" with a constant  
     131        Element metadataList = result_doc.createElement(GSXML.METADATA_ELEM + GSXML.LIST_MODIFIER); 
     132        metadataList.appendChild(GSXML.createMetadataElement(result_doc, "docfilepath", filePath)); //TODO: Replace "docfilepath" with a constant  
    130133        result.appendChild(metadataList); 
    131134 
     
    136139    { 
    137140        //Create a new (empty) result message 
    138         Element result = this.doc.createElement(GSXML.RESPONSE_ELEM); 
     141      Document result_doc = XMLConverter.newDOM(); 
     142        Element result = result_doc.createElement(GSXML.RESPONSE_ELEM); 
    139143        result.setAttribute(GSXML.FROM_ATT, ARCHIVE_GET_SOURCE_FILE_OID); 
    140144        result.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_PROCESS); 
     
    146150        if (param_list == null) 
    147151        { 
    148             GSXML.addError(this.doc, result, ARCHIVE_GET_SOURCE_FILE_OID + ": Missing " + GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER, GSXML.ERROR_TYPE_SYNTAX); 
     152            GSXML.addError(result, ARCHIVE_GET_SOURCE_FILE_OID + ": Missing " + GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER, GSXML.ERROR_TYPE_SYNTAX); 
    149153            return result; 
    150154        } 
     
    160164        } 
    161165 
    162         Element metadataList = this.doc.createElement(GSXML.METADATA_ELEM + GSXML.LIST_MODIFIER); 
    163         metadataList.appendChild(GSXML.createMetadataElement(this.doc, GSXML.NODE_ID_ATT, oid)); 
     166        Element metadataList = result_doc.createElement(GSXML.METADATA_ELEM + GSXML.LIST_MODIFIER); 
     167        metadataList.appendChild(GSXML.createMetadataElement(result_doc, GSXML.NODE_ID_ATT, oid)); 
    164168        result.appendChild(metadataList); 
    165169 
     
    170174    { 
    171175        //Create a new (empty) result message 
    172         Element result = this.doc.createElement(GSXML.RESPONSE_ELEM); 
     176      Document result_doc = XMLConverter.newDOM(); 
     177        Element result = result_doc.createElement(GSXML.RESPONSE_ELEM); 
    173178        result.setAttribute(GSXML.FROM_ATT, ARCHIVE_CHECK_DOCUMENT_OR_SECTION_EXISTS); 
    174179        result.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_PROCESS); 
     
    180185        if (param_list == null) 
    181186        { 
    182             GSXML.addError(this.doc, result, ARCHIVE_CHECK_DOCUMENT_OR_SECTION_EXISTS + ": Missing " + GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER, GSXML.ERROR_TYPE_SYNTAX); 
     187            GSXML.addError(result, ARCHIVE_CHECK_DOCUMENT_OR_SECTION_EXISTS + ": Missing " + GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER, GSXML.ERROR_TYPE_SYNTAX); 
    183188            return result; 
    184189        } 
     
    202207    { 
    203208        //Create a new (empty) result message 
    204         Element result = this.doc.createElement(GSXML.RESPONSE_ELEM); 
     209      Document result_doc = XMLConverter.newDOM(); 
     210        Element result = result_doc.createElement(GSXML.RESPONSE_ELEM); 
    205211        result.setAttribute(GSXML.FROM_ATT, ARCHIVE_WRITE_ENTRY_TO_DATABASE); 
    206212        result.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_PROCESS); 
     
    212218        if (param_list == null) 
    213219        { 
    214             GSXML.addError(this.doc, result, ARCHIVE_WRITE_ENTRY_TO_DATABASE + ": Missing " + GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER, GSXML.ERROR_TYPE_SYNTAX); 
     220            GSXML.addError(result, ARCHIVE_WRITE_ENTRY_TO_DATABASE + ": Missing " + GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER, GSXML.ERROR_TYPE_SYNTAX); 
    215221            return result; 
    216222        } 
     
    262268    { 
    263269        //Create a new (empty) result message 
    264         Element result = this.doc.createElement(GSXML.RESPONSE_ELEM); 
     270      Document result_doc = XMLConverter.newDOM(); 
     271        Element result = result_doc.createElement(GSXML.RESPONSE_ELEM); 
    265272        result.setAttribute(GSXML.FROM_ATT, ARCHIVE_REMOVE_ENTRY_FROM_DATABASE); 
    266273        result.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_PROCESS); 
     
    272279        if (param_list == null) 
    273280        { 
    274             GSXML.addError(this.doc, result, ARCHIVE_REMOVE_ENTRY_FROM_DATABASE + ": Missing " + GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER, GSXML.ERROR_TYPE_SYNTAX); 
     281            GSXML.addError(result, ARCHIVE_REMOVE_ENTRY_FROM_DATABASE + ": Missing " + GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER, GSXML.ERROR_TYPE_SYNTAX); 
    275282            return result; 
    276283        } 
     
    305312    { 
    306313        //Create a new (empty) result message 
    307         Element result = this.doc.createElement(GSXML.RESPONSE_ELEM); 
     314      Document result_doc = XMLConverter.newDOM(); 
     315        Element result = result_doc.createElement(GSXML.RESPONSE_ELEM); 
    308316        result.setAttribute(GSXML.FROM_ATT, ARCHIVE_GET_ASSOCIATED_IMPORT_FILES); 
    309317        result.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_PROCESS); 
     
    315323        if (param_list == null) 
    316324        { 
    317             GSXML.addError(this.doc, result, ARCHIVE_GET_ASSOCIATED_IMPORT_FILES + ": Missing " + GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER, GSXML.ERROR_TYPE_SYNTAX); 
     325            GSXML.addError(result, ARCHIVE_GET_ASSOCIATED_IMPORT_FILES + ": Missing " + GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER, GSXML.ERROR_TYPE_SYNTAX); 
    318326            return result; 
    319327        } 
     
    329337        } 
    330338         
    331         Element metadataList = this.doc.createElement(GSXML.METADATA_ELEM + GSXML.LIST_MODIFIER); 
    332         metadataList.appendChild(GSXML.createMetadataElement(this.doc, "srcfile", assocFiles.get(0))); 
     339        Element metadataList = result_doc.createElement(GSXML.METADATA_ELEM + GSXML.LIST_MODIFIER); 
     340        metadataList.appendChild(GSXML.createMetadataElement(result_doc, "srcfile", assocFiles.get(0))); 
    333341 
    334342        for (int i = 1; i < assocFiles.size(); i++) 
    335343        { 
    336             metadataList.appendChild(GSXML.createMetadataElement(this.doc, "assocfile", assocFiles.get(i))); 
     344            metadataList.appendChild(GSXML.createMetadataElement(result_doc, "assocfile", assocFiles.get(i))); 
    337345        } 
    338346 
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/ArchiveRetrieve.java

    r25635 r28966  
    2626import org.greenstone.gsdl3.util.SimpleCollectionDatabase; 
    2727import org.greenstone.gsdl3.util.UserContext; 
    28  
     28import org.greenstone.gsdl3.util.XMLConverter; 
     29 
     30import org.w3c.dom.Document; 
    2931import org.w3c.dom.Element;  
    3032 
     
    5759        this.config_info = info; 
    5860         
    59         Element documentFilePathRetrieveService = this.doc.createElement(GSXML.SERVICE_ELEM); 
     61        Element documentFilePathRetrieveService = this.desc_doc.createElement(GSXML.SERVICE_ELEM); 
    6062        documentFilePathRetrieveService.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_RETRIEVE); 
    6163        documentFilePathRetrieveService.setAttribute(GSXML.NAME_ATT, DOCUMENT_FILE_PATH_RETRIEVE_SERVICE); 
    6264        this.short_service_info.appendChild(documentFilePathRetrieveService); 
    6365         
    64         Element associatedImportFilesRetrieveService = this.doc.createElement(GSXML.SERVICE_ELEM); 
     66        Element associatedImportFilesRetrieveService = this.desc_doc.createElement(GSXML.SERVICE_ELEM); 
    6567        associatedImportFilesRetrieveService.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_RETRIEVE); 
    6668        associatedImportFilesRetrieveService.setAttribute(GSXML.NAME_ATT, ASSOCIATED_IMPORT_FILES_RETRIEVE_SERVICE); 
    6769        this.short_service_info.appendChild(associatedImportFilesRetrieveService); 
    6870         
    69         Element sourceFileDocIDRetrieveService = this.doc.createElement(GSXML.SERVICE_ELEM); 
     71        Element sourceFileDocIDRetrieveService = this.desc_doc.createElement(GSXML.SERVICE_ELEM); 
    7072        sourceFileDocIDRetrieveService.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_RETRIEVE); 
    7173        sourceFileDocIDRetrieveService.setAttribute(GSXML.NAME_ATT, SOURCE_FILE_OID_RETRIEVE); 
     
    7577    } 
    7678     
    77     protected Element getServiceDescription(String service_id, String lang, String subset)  
     79  protected Element getServiceDescription(Document doc, String service_id, String lang, String subset)  
    7880    { 
    7981        if (service_id.equals(DOCUMENT_FILE_PATH_RETRIEVE_SERVICE))  
    8082        { 
    81             Element service_elem = this.doc.createElement(GSXML.SERVICE_ELEM); 
     83            Element service_elem = doc.createElement(GSXML.SERVICE_ELEM); 
    8284            service_elem.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_RETRIEVE); 
    8385            service_elem.setAttribute(GSXML.NAME_ATT, DOCUMENT_FILE_PATH_RETRIEVE_SERVICE); 
     
    8688        else if (service_id.equals(ASSOCIATED_IMPORT_FILES_RETRIEVE_SERVICE))  
    8789        { 
    88             Element service_elem = this.doc.createElement(GSXML.SERVICE_ELEM); 
     90            Element service_elem = doc.createElement(GSXML.SERVICE_ELEM); 
    8991            service_elem.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_RETRIEVE); 
    9092            service_elem.setAttribute(GSXML.NAME_ATT, ASSOCIATED_IMPORT_FILES_RETRIEVE_SERVICE); 
     
    9395        else if (service_id.equals(SOURCE_FILE_OID_RETRIEVE)) 
    9496        { 
    95             Element service_elem = this.doc.createElement(GSXML.SERVICE_ELEM); 
     97            Element service_elem = doc.createElement(GSXML.SERVICE_ELEM); 
    9698            service_elem.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_RETRIEVE); 
    9799            service_elem.setAttribute(GSXML.NAME_ATT, SOURCE_FILE_OID_RETRIEVE); 
     
    104106    { 
    105107        // Create a new (empty) result message 
    106         Element result = this.doc.createElement(GSXML.RESPONSE_ELEM); 
     108      Document result_doc = XMLConverter.newDOM(); 
     109        Element result = result_doc.createElement(GSXML.RESPONSE_ELEM); 
    107110        result.setAttribute(GSXML.FROM_ATT, DOCUMENT_FILE_PATH_RETRIEVE_SERVICE); 
    108111        result.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_PROCESS); 
     
    113116        Element param_list = (Element) GSXML.getChildByTagName(request, GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER); 
    114117        if (param_list == null) { 
    115             GSXML.addError(this.doc, result, "DocumentFilePathRetrieve: missing "+ GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER, GSXML.ERROR_TYPE_SYNTAX); 
     118            GSXML.addError(result, "DocumentFilePathRetrieve: missing "+ GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER, GSXML.ERROR_TYPE_SYNTAX); 
    116119            return result;   
    117120        } 
     
    130133            "doc.xml"; 
    131134 
    132         Element metadataList = this.doc.createElement(GSXML.METADATA_ELEM + GSXML.LIST_MODIFIER); 
    133         metadataList.appendChild(createMetadataElement("docfilepath", docFilePath)); 
     135        Element metadataList = result_doc.createElement(GSXML.METADATA_ELEM + GSXML.LIST_MODIFIER); 
     136        metadataList.appendChild(GSXML.createMetadataElement(result_doc, "docfilepath", docFilePath)); 
    134137        result.appendChild(metadataList); 
    135138         
     
    140143    { 
    141144        //Create a new (empty) result message 
    142         Element result = this.doc.createElement(GSXML.RESPONSE_ELEM); 
     145      Document result_doc = XMLConverter.newDOM(); 
     146        Element result = result_doc.createElement(GSXML.RESPONSE_ELEM); 
    143147        result.setAttribute(GSXML.FROM_ATT, SOURCE_FILE_OID_RETRIEVE); 
    144148        result.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_PROCESS); 
     
    150154        if (param_list == null)  
    151155        { 
    152             GSXML.addError(this.doc, result, "DocumentFilePathRetrieve: missing "+ GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER, GSXML.ERROR_TYPE_SYNTAX); 
     156            GSXML.addError(result, "DocumentFilePathRetrieve: missing "+ GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER, GSXML.ERROR_TYPE_SYNTAX); 
    153157            return result;   
    154158        } 
     
    201205        String oid = info.getInfo("oid"); 
    202206         
    203         Element metadataList = this.doc.createElement(GSXML.METADATA_ELEM + GSXML.LIST_MODIFIER); 
    204         metadataList.appendChild(createMetadataElement("oid", oid)); 
     207        Element metadataList = result_doc.createElement(GSXML.METADATA_ELEM + GSXML.LIST_MODIFIER); 
     208        metadataList.appendChild(GSXML.createMetadataElement(result_doc, "oid", oid)); 
    205209        result.appendChild(metadataList); 
    206210         
     
    211215    { 
    212216        //Create a new (empty) result message 
    213         Element result = this.doc.createElement(GSXML.RESPONSE_ELEM); 
     217      Document result_doc = XMLConverter.newDOM(); 
     218        Element result = result_doc.createElement(GSXML.RESPONSE_ELEM); 
    214219        result.setAttribute(GSXML.FROM_ATT, ASSOCIATED_IMPORT_FILES_RETRIEVE_SERVICE); 
    215220        result.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_PROCESS); 
     
    221226        if (param_list == null)  
    222227        { 
    223             GSXML.addError(this.doc, result, "AssociatedImportFilesRetrieve: missing "+ GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER, GSXML.ERROR_TYPE_SYNTAX); 
     228            GSXML.addError(result, "AssociatedImportFilesRetrieve: missing "+ GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER, GSXML.ERROR_TYPE_SYNTAX); 
    224229            return result;   
    225230        } 
     
    272277        Vector<String> data = info.getMultiInfo("assoc-file"); 
    273278         
    274         Element metadataList = this.doc.createElement(GSXML.METADATA_ELEM + GSXML.LIST_MODIFIER); 
    275         metadataList.appendChild(createMetadataElement("srcfile", srcFile)); 
     279        Element metadataList = result_doc.createElement(GSXML.METADATA_ELEM + GSXML.LIST_MODIFIER); 
     280        metadataList.appendChild(GSXML.createMetadataElement(result_doc, "srcfile", srcFile)); 
    276281         
    277282        for (int i = 0; i < data.size(); i++) 
    278283        { 
    279             metadataList.appendChild(createMetadataElement("assocfile", data.get(i))); 
     284          metadataList.appendChild(GSXML.createMetadataElement(result_doc, "assocfile", data.get(i))); 
    280285        } 
    281286         
     
    285290    } 
    286291     
    287     public Element createMetadataElement(String name, String value) 
    288     { 
    289         Element metaElem = this.doc.createElement(GSXML.METADATA_ELEM); 
    290         metaElem.setAttribute("name", name); 
    291         metaElem.setAttribute("value", value); 
    292         return metaElem; 
    293     } 
    294292     
    295293    public String getAssocFilePathFromDocID(String oid, String collection, UserContext userContext) 
    296294    { 
    297         Element mr_query_message = this.doc.createElement(GSXML.MESSAGE_ELEM); 
    298         Element mr_query_request = GSXML.createBasicRequest (this.doc, GSXML.REQUEST_TYPE_PAGE, collection + "/DocumentMetadataRetrieve", userContext); 
     295      Document doc = XMLConverter.newDOM(); 
     296        Element mr_query_message = doc.createElement(GSXML.MESSAGE_ELEM); 
     297        Element mr_query_request = GSXML.createBasicRequest (doc, GSXML.REQUEST_TYPE_PAGE, collection + "/DocumentMetadataRetrieve", userContext); 
    299298        mr_query_message.appendChild(mr_query_request); 
    300299         
    301         Element paramList = this.doc.createElement(GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER); 
    302         paramList.appendChild(createMetadataElement("metadata", "assocfilepath")); 
     300        Element paramList = doc.createElement(GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER); 
     301        paramList.appendChild(GSXML.createMetadataElement(doc, "metadata", "assocfilepath")); 
    303302         
    304303        mr_query_request.appendChild(paramList); 
    305304 
    306         Element docListElem = this.doc.createElement(GSXML.DOC_NODE_ELEM+GSXML.LIST_MODIFIER); 
    307         Element docElem = this.doc.createElement(GSXML.DOC_NODE_ELEM); 
     305        Element docListElem = doc.createElement(GSXML.DOC_NODE_ELEM+GSXML.LIST_MODIFIER); 
     306        Element docElem = doc.createElement(GSXML.DOC_NODE_ELEM); 
    308307        docElem.setAttribute(GSXML.NODE_ID_ATT, oid); 
    309308        docListElem.appendChild(docElem); 
     
    324323    { 
    325324        //Find out what kind of database we have 
    326         Element dbTypeMessage = this.doc.createElement(GSXML.MESSAGE_ELEM); 
    327         Element dbTypeRequest = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, collection, userContext); 
     325      Document doc = XMLConverter.newDOM(); 
     326        Element dbTypeMessage = doc.createElement(GSXML.MESSAGE_ELEM); 
     327        Element dbTypeRequest = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_DESCRIBE, collection, userContext); 
    328328        dbTypeMessage.appendChild(dbTypeRequest); 
    329329        Element dbTypeResponse = (Element)this.router.process(dbTypeMessage); 
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/Authentication.java

    r28958 r28966  
    1919import org.greenstone.gsdl3.util.UserQueryResult; 
    2020import org.greenstone.gsdl3.util.UserTermInfo; 
     21import org.greenstone.gsdl3.util.XMLConverter; 
    2122import org.greenstone.util.GlobalProperties; 
     23 
     24import org.w3c.dom.Document; 
    2225import org.w3c.dom.Element; 
    2326import org.w3c.dom.NodeList; 
     
    168171 
    169172        // set up Authentication service info - for now just has name and type 
    170         Element authentication_service = this.doc.createElement(GSXML.SERVICE_ELEM); 
     173        Element authentication_service = this.desc_doc.createElement(GSXML.SERVICE_ELEM); 
    171174        authentication_service.setAttribute(GSXML.TYPE_ATT, "authen"); 
    172175        authentication_service.setAttribute(GSXML.NAME_ATT, AUTHENTICATION_SERVICE); 
    173176        this.short_service_info.appendChild(authentication_service); 
    174177 
    175         Element getUserInformation_service = this.doc.createElement(GSXML.SERVICE_ELEM); 
     178        Element getUserInformation_service = this.desc_doc.createElement(GSXML.SERVICE_ELEM); 
    176179        getUserInformation_service.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_PROCESS); 
    177180        getUserInformation_service.setAttribute(GSXML.NAME_ATT, GET_USER_INFORMATION_SERVICE); 
    178181        this.short_service_info.appendChild(getUserInformation_service); 
    179182 
    180         Element changeEditMode_service = this.doc.createElement(GSXML.SERVICE_ELEM); 
     183        Element changeEditMode_service = this.desc_doc.createElement(GSXML.SERVICE_ELEM); 
    181184        changeEditMode_service.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_PROCESS); 
    182185        changeEditMode_service.setAttribute(GSXML.NAME_ATT, CHANGE_USER_EDIT_MODE_SERVICE); 
    183186        this.short_service_info.appendChild(changeEditMode_service); 
    184187         
    185         Element remoteAuthentication_service = this.doc.createElement(GSXML.SERVICE_ELEM); 
     188        Element remoteAuthentication_service = this.desc_doc.createElement(GSXML.SERVICE_ELEM); 
    186189        remoteAuthentication_service.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_PROCESS); 
    187190        remoteAuthentication_service.setAttribute(GSXML.NAME_ATT, REMOTE_AUTHENTICATION_SERVICE); 
     
    214217    } 
    215218 
    216     protected Element getServiceDescription(String service_id, String lang, String subset) 
    217     { 
    218  
    219         Element authen_service = this.doc.createElement(GSXML.SERVICE_ELEM); 
     219  protected Element getServiceDescription(Document doc, String service_id, String lang, String subset) 
     220    { 
     221 
     222        Element authen_service = doc.createElement(GSXML.SERVICE_ELEM); 
    220223 
    221224        if (service_id.equals(AUTHENTICATION_SERVICE)) 
     
    246249        if (service_id.equals(AUTHENTICATION_SERVICE) && (subset == null || subset.equals(GSXML.DISPLAY_TEXT_ELEM + GSXML.LIST_MODIFIER))) 
    247250        { 
    248             authen_service.appendChild(GSXML.createDisplayTextElement(this.doc, GSXML.DISPLAY_TEXT_NAME, getServiceName(service_id, lang))); 
    249             authen_service.appendChild(GSXML.createDisplayTextElement(this.doc, GSXML.DISPLAY_TEXT_DESCRIPTION, getServiceDescription(service_id, lang))); 
     251            authen_service.appendChild(GSXML.createDisplayTextElement(doc, GSXML.DISPLAY_TEXT_NAME, getServiceName(service_id, lang))); 
     252            authen_service.appendChild(GSXML.createDisplayTextElement(doc, GSXML.DISPLAY_TEXT_DESCRIPTION, getServiceDescription(service_id, lang))); 
    250253        } 
    251254        return authen_service; 
     
    270273    { 
    271274        // Create a new (empty) result message 
    272         Element result = this.doc.createElement(GSXML.RESPONSE_ELEM); 
     275      Document result_doc = XMLConverter.newDOM(); 
     276        Element result = result_doc.createElement(GSXML.RESPONSE_ELEM); 
    273277 
    274278        result.setAttribute(GSXML.FROM_ATT, CHANGE_USER_EDIT_MODE_SERVICE); 
     
    278282        if (paramList == null) 
    279283        { 
    280             GSXML.addError(this.doc, result, _errorMessageMap.get(ERROR_REQUEST_HAS_NO_PARAM_LIST)); 
     284            GSXML.addError(result, _errorMessageMap.get(ERROR_REQUEST_HAS_NO_PARAM_LIST)); 
    281285            return result; 
    282286        } 
     
    362366            } 
    363367        } 
    364          
    365         Element result = this.doc.createElement(GSXML.RESPONSE_ELEM); 
     368        Document result_doc = XMLConverter.newDOM(); 
     369        Element result = result_doc.createElement(GSXML.RESPONSE_ELEM); 
    366370        result.setAttribute(GSXML.FROM_ATT, REMOTE_AUTHENTICATION_SERVICE); 
    367371        result.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_PROCESS);         
    368         Element s = GSXML.createTextElement(this.doc, GSXML.STATUS_ELEM, message); 
     372        Element s = GSXML.createTextElement(result_doc, GSXML.STATUS_ELEM, message); 
    369373        result.appendChild(s); 
    370374        return result; 
     
    374378    { 
    375379        // Create a new (empty) result message 
    376         Element result = this.doc.createElement(GSXML.RESPONSE_ELEM); 
     380      Document result_doc = XMLConverter.newDOM(); 
     381        Element result = result_doc.createElement(GSXML.RESPONSE_ELEM); 
    377382 
    378383        result.setAttribute(GSXML.FROM_ATT, GET_USER_INFORMATION_SERVICE); 
     
    382387        if (paramList == null) 
    383388        { 
    384             GSXML.addError(this.doc, result, _errorMessageMap.get(ERROR_REQUEST_HAS_NO_PARAM_LIST)); 
     389            GSXML.addError(result, _errorMessageMap.get(ERROR_REQUEST_HAS_NO_PARAM_LIST)); 
    385390            return result; 
    386391        } 
     
    392397        if (username == null) 
    393398        { 
    394             GSXML.addError(this.doc, result, _errorMessageMap.get(ERROR_USERNAME_NOT_SPECIFIED)); 
     399            GSXML.addError(result, _errorMessageMap.get(ERROR_USERNAME_NOT_SPECIFIED)); 
    395400            return result; 
    396401        } 
     
    405410        if (terms.size() == 0) 
    406411        { 
    407             GSXML.addError(this.doc, result, _errorMessageMap.get(ERROR_REQUESTED_USER_NOT_FOUND)); 
     412            GSXML.addError(result, _errorMessageMap.get(ERROR_REQUESTED_USER_NOT_FOUND)); 
    408413            return result; 
    409414        } 
    410415 
    411416        UserTermInfo userInfo = terms.get(0); 
    412         Element userInfoList = this.doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER); 
     417        Element userInfoList = result_doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER); 
    413418        result.appendChild(userInfoList); 
    414419 
    415         Element usernameField = GSXML.createParameter(this.doc, "username", userInfo.username); 
    416         Element passwordField = GSXML.createParameter(this.doc, "password", userInfo.password); 
    417         Element groupsField = GSXML.createParameter(this.doc, "groups", userInfo.groups); 
    418         Element accountStatusField = GSXML.createParameter(this.doc, "accountstatus", userInfo.accountstatus); 
    419         Element commentField = GSXML.createParameter(this.doc, "comment", userInfo.comment); 
     420        Element usernameField = GSXML.createParameter(result_doc, "username", userInfo.username); 
     421        Element passwordField = GSXML.createParameter(result_doc, "password", userInfo.password); 
     422        Element groupsField = GSXML.createParameter(result_doc, "groups", userInfo.groups); 
     423        Element accountStatusField = GSXML.createParameter(result_doc, "accountstatus", userInfo.accountstatus); 
     424        Element commentField = GSXML.createParameter(result_doc, "comment", userInfo.comment); 
    420425 
    421426        if (editEnabled != null) 
    422427        { 
    423             Element editEnabledElem = GSXML.createParameter(this.doc, "editEnabled", editEnabled); 
     428            Element editEnabledElem = GSXML.createParameter(result_doc, "editEnabled", editEnabled); 
    424429            userInfoList.appendChild(editEnabledElem); 
    425430        } 
     
    441446 
    442447        // Create a new (empty) result message 
    443         Element result = this.doc.createElement(GSXML.RESPONSE_ELEM); 
     448        Document result_doc = XMLConverter.newDOM(); 
     449        Element result = result_doc.createElement(GSXML.RESPONSE_ELEM); 
    444450        result.setAttribute(GSXML.FROM_ATT, AUTHENTICATION_SERVICE); 
    445451        result.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_PROCESS); 
    446452 
    447453        // Create an Authentication node put into the result 
    448         Element authenNode = this.doc.createElement(GSXML.AUTHEN_NODE_ELEM); 
     454        Element authenNode = result_doc.createElement(GSXML.AUTHEN_NODE_ELEM); 
    449455        result.appendChild(authenNode); 
    450         result.appendChild(getCollectList(this.site_home + File.separatorChar + "collect")); 
     456        result.appendChild(getCollectList(result_doc, this.site_home + File.separatorChar + "collect")); 
    451457 
    452458        // Create a service node added into the Authentication node 
    453         Element serviceNode = this.doc.createElement(GSXML.SERVICE_ELEM); 
     459        Element serviceNode = result_doc.createElement(GSXML.SERVICE_ELEM); 
    454460        authenNode.appendChild(serviceNode); 
    455461 
     
    459465        { 
    460466            serviceNode.setAttribute("operation", LOGIN); 
    461             GSXML.addError(this.doc, result, _errorMessageMap.get(ERROR_REQUEST_HAS_NO_PARAM_LIST)); 
     467            GSXML.addError(result, _errorMessageMap.get(ERROR_REQUEST_HAS_NO_PARAM_LIST)); 
    462468            return result; // Return the empty result 
    463469        } 
     
    473479        { 
    474480            serviceNode.setAttribute("operation", LOGIN); 
    475             GSXML.addError(this.doc, result, _errorMessageMap.get(ERROR_NOT_LOGGED_IN)); 
     481            GSXML.addError(result, _errorMessageMap.get(ERROR_NOT_LOGGED_IN)); 
    476482            return result; 
    477483        } 
     
    486492        { 
    487493            serviceNode.setAttribute("operation", LOGIN); 
    488             GSXML.addError(this.doc, result, _errorMessageMap.get(ERROR_NOT_LOGGED_IN)); 
     494            GSXML.addError(result, _errorMessageMap.get(ERROR_NOT_LOGGED_IN)); 
    489495            return result; 
    490496        } 
     
    493499        { 
    494500            serviceNode.setAttribute("operation", LOGIN); 
    495             GSXML.addError(this.doc, result, _errorMessageMap.get(ERROR_ADMIN_NOT_LOGGED_IN)); 
     501            GSXML.addError(result, _errorMessageMap.get(ERROR_ADMIN_NOT_LOGGED_IN)); 
    496502            return result; 
    497503        } 
     
    502508            if (error != NO_ERROR) 
    503509            { 
    504                 GSXML.addError(this.doc, result, _errorMessageMap.get(error)); 
     510                GSXML.addError(result, _errorMessageMap.get(error)); 
    505511            } 
    506512        } 
     
    518524            if ((error = checkUsername(newUsername)) != NO_ERROR) 
    519525            { 
    520                 GSXML.addError(this.doc, result, _errorMessageMap.get(error)); 
     526                GSXML.addError(result, _errorMessageMap.get(error)); 
    521527                return result; 
    522528            } 
     
    525531            if ((error = checkPassword(newPassword)) != NO_ERROR) 
    526532            { 
    527                 GSXML.addError(this.doc, result, _errorMessageMap.get(error)); 
     533                GSXML.addError(result, _errorMessageMap.get(error)); 
    528534                return result; 
    529535            } 
     
    535541            { 
    536542                serviceNode.setAttribute("operation", ADD_USER); 
    537                 GSXML.addError(this.doc, result, _errorMessageMap.get(error)); 
     543                GSXML.addError(result, _errorMessageMap.get(error)); 
    538544            } 
    539545            else 
     
    553559            if ((error = checkUsername(newUsername)) != NO_ERROR) 
    554560            { 
    555                 GSXML.addError(this.doc, result, _errorMessageMap.get(error)); 
     561                GSXML.addError(result, _errorMessageMap.get(error)); 
    556562                return result; 
    557563            } 
     
    560566            if ((error = checkPassword(newPassword)) != NO_ERROR) 
    561567            { 
    562                 GSXML.addError(this.doc, result, _errorMessageMap.get(error)); 
     568                GSXML.addError(result, _errorMessageMap.get(error)); 
    563569                return result; 
    564570            } 
     
    584590                    { 
    585591                        serviceNode.setAttribute("operation", REGISTER); 
    586                         GSXML.addError(this.doc, result, _errorMessageMap.get(ERROR_CAPTCHA_MISSING)); 
     592                        GSXML.addError(result, _errorMessageMap.get(ERROR_CAPTCHA_MISSING)); 
    587593                        return result; 
    588594                    } 
     
    593599                    { 
    594600                        serviceNode.setAttribute("operation", REGISTER); 
    595                         GSXML.addError(this.doc, result, _errorMessageMap.get(ERROR_CAPTCHA_DOES_NOT_MATCH)); 
     601                        GSXML.addError(result, _errorMessageMap.get(ERROR_CAPTCHA_DOES_NOT_MATCH)); 
    596602                        return result; 
    597603                    } 
     
    606612            { 
    607613                serviceNode.setAttribute("operation", REGISTER); 
    608                 GSXML.addError(this.doc, result, _errorMessageMap.get(error)); 
     614                GSXML.addError(result, _errorMessageMap.get(error)); 
    609615            } 
    610616        } 
     
    623629            if ((error = checkUsername(newUsername)) != NO_ERROR) 
    624630            { 
    625                 GSXML.addError(this.doc, result, _errorMessageMap.get(error)); 
     631                GSXML.addError(result, _errorMessageMap.get(error)); 
    626632                return result; 
    627633            } 
     
    636642                if ((error = checkPassword(newPassword)) != NO_ERROR) 
    637643                { 
    638                     GSXML.addError(this.doc, result, _errorMessageMap.get(error)); 
     644                    GSXML.addError(result, _errorMessageMap.get(error)); 
    639645                    return result; 
    640646                } 
     
    654660                { 
    655661                    serviceNode.setAttribute("operation", EDIT_USER); 
    656                     GSXML.addError(this.doc, result, _errorMessageMap.get(error)); 
     662                    GSXML.addError(result, _errorMessageMap.get(error)); 
    657663                } 
    658664                return result; 
     
    663669            { 
    664670                serviceNode.setAttribute("operation", EDIT_USER); 
    665                 GSXML.addError(this.doc, result, _errorMessageMap.get(error)); 
     671                GSXML.addError(result, _errorMessageMap.get(error)); 
    666672            } 
    667673            else 
     
    684690                addUserInformationToNode(previousUsername, serviceNode); 
    685691                serviceNode.setAttribute("operation", ACCOUNT_SETTINGS); 
    686                 GSXML.addError(this.doc, result, _errorMessageMap.get(ERROR_USER_ALREADY_EXISTS)); 
     692                GSXML.addError(result, _errorMessageMap.get(ERROR_USER_ALREADY_EXISTS)); 
    687693                return result; 
    688694            } 
     
    698704                    addUserInformationToNode(previousUsername, serviceNode); 
    699705                    serviceNode.setAttribute("operation", ACCOUNT_SETTINGS); 
    700                     GSXML.addError(this.doc, result, _errorMessageMap.get(ERROR_INCORRECT_PASSWORD), "Incorrect Password"); 
     706                    GSXML.addError(result, _errorMessageMap.get(ERROR_INCORRECT_PASSWORD), "Incorrect Password"); 
    701707                    return result; 
    702708                } 
     
    706712                if ((error = checkPassword(newPassword)) != NO_ERROR) 
    707713                { 
    708                     GSXML.addError(this.doc, result, _errorMessageMap.get(error)); 
     714                    GSXML.addError(result, _errorMessageMap.get(error)); 
    709715                    return result; 
    710716                } 
     
    721727            if ((error = checkUsername(newUsername)) != NO_ERROR) 
    722728            { 
    723                 GSXML.addError(this.doc, result, _errorMessageMap.get(error)); 
     729                GSXML.addError(result, _errorMessageMap.get(error)); 
    724730                return result; 
    725731            } 
     
    741747                    addUserInformationToNode(previousUsername, serviceNode); 
    742748                    serviceNode.setAttribute("operation", ACCOUNT_SETTINGS); 
    743                     GSXML.addError(this.doc, result, _errorMessageMap.get(error)); 
     749                    GSXML.addError(result, _errorMessageMap.get(error)); 
    744750                } 
    745751                return result; 
     
    749755            if (error != NO_ERROR) 
    750756            { 
    751                 GSXML.addError(this.doc, result, _errorMessageMap.get(error)); 
     757                GSXML.addError(result, _errorMessageMap.get(error)); 
    752758            } 
    753759 
     
    767773            if (user_name == null || oldPassword == null || newPassword == null) 
    768774            { 
    769                 GSXML.addError(this.doc, result, _errorMessageMap.get("missing compulsory parameters: username, oldPassword, or newPassword")); 
     775                GSXML.addError(result, _errorMessageMap.get("missing compulsory parameters: username, oldPassword, or newPassword")); 
    770776                return result; 
    771777            } 
     
    775781            { 
    776782                addUserInformationToNode(user_name, serviceNode); 
    777                 GSXML.addError(this.doc, result, _errorMessageMap.get(ERROR_INCORRECT_PASSWORD), "Incorrect Password"); 
     783                GSXML.addError(result, _errorMessageMap.get(ERROR_INCORRECT_PASSWORD), "Incorrect Password"); 
    778784                return result; 
    779785            } 
     
    783789            if ((error = checkPassword(newPassword)) != NO_ERROR) 
    784790            { 
    785                 GSXML.addError(this.doc, result, _errorMessageMap.get(error)); 
     791                GSXML.addError(result, _errorMessageMap.get(error)); 
    786792                return result; 
    787793            } 
     
    794800            if (info != "succeed") 
    795801            {//see DerbyWrapper.modifyUserInfo 
    796                 GSXML.addError(this.doc, result, _errorMessageMap.get(info)); 
     802                GSXML.addError(result, _errorMessageMap.get(info)); 
    797803                return result; 
    798804            } 
     
    804810            if (error != NO_ERROR) 
    805811            { 
    806                 GSXML.addError(this.doc, result, _errorMessageMap.get(error)); 
     812                GSXML.addError(result, _errorMessageMap.get(error)); 
    807813            } 
    808814        } 
     
    814820            { 
    815821                serviceNode.setAttribute("operation", ""); 
    816                 GSXML.addError(this.doc, result, _errorMessageMap.get(ERROR_USERNAME_NOT_SPECIFIED)); 
     822                GSXML.addError(result, _errorMessageMap.get(ERROR_USERNAME_NOT_SPECIFIED)); 
    817823                return result; 
    818824            } 
     
    821827            { 
    822828                serviceNode.setAttribute("operation", LOGIN); 
    823                 GSXML.addError(this.doc, result, _errorMessageMap.get(ERROR_NOT_AUTHORISED)); 
     829                GSXML.addError(result, _errorMessageMap.get(ERROR_NOT_AUTHORISED)); 
    824830                return result; 
    825831            } 
     
    827833            if (error != NO_ERROR) 
    828834            { 
    829                 GSXML.addError(this.doc, result, _errorMessageMap.get(error)); 
     835                GSXML.addError(result, _errorMessageMap.get(error)); 
    830836            } 
    831837        } 
     
    861867            if (_recaptchaPublicKey != null && _recaptchaPrivateKey != null) 
    862868            { 
    863                 Element recaptchaElem = this.doc.createElement("recaptcha"); 
     869                Element recaptchaElem = result_doc.createElement("recaptcha"); 
    864870                recaptchaElem.setAttribute("publicKey", _recaptchaPublicKey); 
    865871                recaptchaElem.setAttribute("privateKey", _recaptchaPrivateKey); 
     
    873879            if (error != NO_ERROR) 
    874880            { 
    875                 GSXML.addError(this.doc, result, _errorMessageMap.get(error)); 
     881                GSXML.addError(result, _errorMessageMap.get(error)); 
    876882            } 
    877883            addUserInformationToNode(null, serviceNode); 
     
    985991        if (userQueryResult != null) 
    986992        { 
    987             Element user_node = getUserNode(userQueryResult); 
     993          Element user_node = getUserNodeList(serviceNode.getOwnerDocument(), userQueryResult); 
    988994            serviceNode.appendChild(user_node); 
    989995            return NO_ERROR; 
     
    11141120    } 
    11151121 
    1116     private Element getUserNode(UserQueryResult userQueryResult) 
    1117     { 
    1118         Element user_list_node = this.doc.createElement(GSXML.USER_NODE_ELEM + "List"); 
     1122  private Element getUserNodeList(Document doc, UserQueryResult userQueryResult) 
     1123    { 
     1124        Element user_list_node = doc.createElement(GSXML.USER_NODE_ELEM + GSXML.LIST_MODIFIER); 
    11191125 
    11201126        Vector userInfo = userQueryResult.users; 
     
    11221128        for (int i = 0; i < userQueryResult.getSize(); i++) 
    11231129        { 
    1124             Element user_node = this.doc.createElement(GSXML.USER_NODE_ELEM); 
     1130            Element user_node = doc.createElement(GSXML.USER_NODE_ELEM); 
    11251131            String username = ((UserTermInfo) userInfo.get(i)).username; 
    11261132            String groups = ((UserTermInfo) userInfo.get(i)).groups; 
     
    11391145    } 
    11401146 
    1141     private Element getCollectList(String collect) 
    1142     { 
    1143         Element collect_list_node = this.doc.createElement(GSXML.COLLECTION_ELEM + "List"); 
     1147  private Element getCollectList(Document doc, String collect) 
     1148    { 
     1149        Element collect_list_node = doc.createElement(GSXML.COLLECTION_ELEM + GSXML.LIST_MODIFIER); 
    11441150        File[] collect_dir = (new File(collect)).listFiles(); 
    11451151        if (collect_dir != null && collect_dir.length > 0) 
     
    11491155                if (collect_dir[i].isDirectory() && (!collect_dir[i].getName().startsWith(".svn"))) 
    11501156                { 
    1151                     Element collect_node = this.doc.createElement(GSXML.COLLECTION_ELEM); 
    1152                     collect_node.setAttribute("name", collect_dir[i].getName()); 
     1157                    Element collect_node = doc.createElement(GSXML.COLLECTION_ELEM); 
     1158                    collect_node.setAttribute(GSXML.NAME_ATT, collect_dir[i].getName()); 
    11531159                    collect_list_node.appendChild(collect_node); 
    11541160                } 
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/BerryBasket.java

    r25635 r28966  
    2727import java.util.Iterator; 
    2828 
     29import org.w3c.dom.Document; 
    2930import org.w3c.dom.Element; 
    3031import org.w3c.dom.NodeList; 
     
    3435import org.greenstone.gsdl3.util.GSPath; 
    3536import org.greenstone.gsdl3.util.UserContext; 
     37import org.greenstone.gsdl3.util.XMLConverter; 
    3638 
    3739import java.io.Serializable; 
     
    111113 
    112114        // set up short_service_info_ - for now just has name and type 
    113         Element add_service = this.doc.createElement(GSXML.SERVICE_ELEM); 
     115        Element add_service = this.desc_doc.createElement(GSXML.SERVICE_ELEM); 
    114116        add_service.setAttribute(GSXML.TYPE_ATT, "gather"); // what?? 
    115117        add_service.setAttribute(GSXML.NAME_ATT, ADD_ITEM_SERVICE); 
     
    117119 
    118120        // set up short_service_info_ - for now just has name and type 
    119         Element disp_service = this.doc.createElement(GSXML.SERVICE_ELEM); 
     121        Element disp_service = this.desc_doc.createElement(GSXML.SERVICE_ELEM); 
    120122        disp_service.setAttribute(GSXML.TYPE_ATT, "gather"); // what?? 
    121123        disp_service.setAttribute(GSXML.NAME_ATT, DISPLAY_ITEMS_SERVICE); 
     
    123125 
    124126        // set up short_service_info_ - for now just has name and type 
    125         Element num_service = this.doc.createElement(GSXML.SERVICE_ELEM); 
     127        Element num_service = this.desc_doc.createElement(GSXML.SERVICE_ELEM); 
    126128        num_service.setAttribute(GSXML.TYPE_ATT, "gather"); // what?? 
    127129        num_service.setAttribute(GSXML.NAME_ATT, ITEM_NUM_SERVICE); 
     
    129131 
    130132        // set up short_service_info_ - for now just has name and type 
    131         Element delete_service = this.doc.createElement(GSXML.SERVICE_ELEM); 
     133        Element delete_service = this.desc_doc.createElement(GSXML.SERVICE_ELEM); 
    132134        delete_service.setAttribute(GSXML.TYPE_ATT, "gather"); // what?? 
    133135        delete_service.setAttribute(GSXML.NAME_ATT, DELETE_ITEMS_SERVICE); 
     
    135137 
    136138        // set up short_service_info_ - for now just has name and type 
    137         Element deleteone_service = this.doc.createElement(GSXML.SERVICE_ELEM); 
     139        Element deleteone_service = this.desc_doc.createElement(GSXML.SERVICE_ELEM); 
    138140        deleteone_service.setAttribute(GSXML.TYPE_ATT, "gather"); // what?? 
    139141        deleteone_service.setAttribute(GSXML.NAME_ATT, DELETE_ITEM_SERVICE); 
     
    141143 
    142144        // set up short_service_info_ - for now just has name and type 
    143         Element mail_service = this.doc.createElement(GSXML.SERVICE_ELEM); 
     145        Element mail_service = this.desc_doc.createElement(GSXML.SERVICE_ELEM); 
    144146        mail_service.setAttribute(GSXML.TYPE_ATT, "gather"); // what?? 
    145147        mail_service.setAttribute(GSXML.NAME_ATT, SEND_MAIL_SERVICE); 
     
    151153 
    152154    /** returns a specific service description */ 
    153     protected Element getServiceDescription(String service_id, String lang, String subset) 
     155  protected Element getServiceDescription(Document doc, String service_id, String lang, String subset) 
    154156    { 
    155157 
    156158        if (service_id.equals(ADD_ITEM_SERVICE)) 
    157159        { 
    158             Element add_service = this.doc.createElement(GSXML.SERVICE_ELEM); 
     160            Element add_service = doc.createElement(GSXML.SERVICE_ELEM); 
    159161            add_service.setAttribute(GSXML.TYPE_ATT, "gather"); // what?? 
    160162            add_service.setAttribute(GSXML.NAME_ATT, ADD_ITEM_SERVICE); 
     
    164166        { 
    165167 
    166             Element disp_service = this.doc.createElement(GSXML.SERVICE_ELEM); 
     168            Element disp_service = doc.createElement(GSXML.SERVICE_ELEM); 
    167169            disp_service.setAttribute(GSXML.TYPE_ATT, "gather"); // what?? 
    168170            disp_service.setAttribute(GSXML.NAME_ATT, DISPLAY_ITEMS_SERVICE); 
     
    173175        { 
    174176 
    175             Element num_service = this.doc.createElement(GSXML.SERVICE_ELEM); 
     177            Element num_service = doc.createElement(GSXML.SERVICE_ELEM); 
    176178            num_service.setAttribute(GSXML.TYPE_ATT, "gather"); // what?? 
    177179            num_service.setAttribute(GSXML.NAME_ATT, ITEM_NUM_SERVICE); 
     
    182184        { 
    183185 
    184             Element del_service = this.doc.createElement(GSXML.SERVICE_ELEM); 
     186            Element del_service = doc.createElement(GSXML.SERVICE_ELEM); 
    185187            del_service.setAttribute(GSXML.TYPE_ATT, "gather"); // what?? 
    186188            del_service.setAttribute(GSXML.NAME_ATT, DELETE_ITEMS_SERVICE); 
     
    191193        { 
    192194 
    193             Element delone_service = this.doc.createElement(GSXML.SERVICE_ELEM); 
     195            Element delone_service = doc.createElement(GSXML.SERVICE_ELEM); 
    194196            delone_service.setAttribute(GSXML.TYPE_ATT, "gather"); // what?? 
    195197            delone_service.setAttribute(GSXML.NAME_ATT, DELETE_ITEM_SERVICE); 
     
    200202        { 
    201203 
    202             Element mail_service = this.doc.createElement(GSXML.SERVICE_ELEM); 
     204            Element mail_service = doc.createElement(GSXML.SERVICE_ELEM); 
    203205            mail_service.setAttribute(GSXML.TYPE_ATT, "gather"); // what?? 
    204206            mail_service.setAttribute(GSXML.NAME_ATT, SEND_MAIL_SERVICE); 
     
    214216 
    215217        // Create a new (empty) result message 
    216         Element result = this.doc.createElement(GSXML.RESPONSE_ELEM); 
     218        Document result_doc = XMLConverter.newDOM(); 
     219        Element result = result_doc.createElement(GSXML.RESPONSE_ELEM); 
    217220 
    218221        // Get the parameters of the request 
     
    242245                Item newItem = generateItem(collection, item); 
    243246                items.put(item, newItem); 
    244                 result.appendChild(newItem.wrapIntoElement()); 
     247                result.appendChild(newItem.wrapIntoElement(result_doc)); 
    245248            } 
    246249        } 
     
    251254            items.put(item, newItem); 
    252255            docsMap.put(collection, items); 
    253             result.appendChild(newItem.wrapIntoElement()); 
     256            result.appendChild(newItem.wrapIntoElement(result_doc)); 
    254257        } 
    255258 
     
    307310 
    308311        // Create a new (empty) result message 
    309         Element result = this.doc.createElement(GSXML.RESPONSE_ELEM); 
     312        Document result_doc = XMLConverter.newDOM(); 
     313        Element result = result_doc.createElement(GSXML.RESPONSE_ELEM); 
    310314 
    311315        // Get the parameters of the request 
     
    363367 
    364368        // Create a new (empty) result message 
    365         Element result = this.doc.createElement(GSXML.RESPONSE_ELEM); 
     369        Document result_doc = XMLConverter.newDOM(); 
     370        Element result = result_doc.createElement(GSXML.RESPONSE_ELEM); 
    366371 
    367372        // Get the parameters of the request 
     
    413418 
    414419        // Create a new (empty) result message 
    415         Element result = this.doc.createElement(GSXML.RESPONSE_ELEM); 
     420        Document result_doc = XMLConverter.newDOM(); 
     421        Element result = result_doc.createElement(GSXML.RESPONSE_ELEM); 
    416422 
    417423        int size = 0; 
     
    427433            { 
    428434                Item item = (Item) values.next(); 
    429                 result.appendChild(item.wrapIntoElement()); 
    430             } 
    431         } 
    432  
    433         Element selement = this.doc.createElement("size"); 
     435                result.appendChild(item.wrapIntoElement(result_doc)); 
     436            } 
     437        } 
     438 
     439        Element selement = result_doc.createElement("size"); 
    434440        selement.setAttribute("value", size + ""); 
    435441        result.appendChild(selement); 
     
    442448 
    443449        // Build a request to obtain some document metadata 
    444         Element dm_message = this.doc.createElement(GSXML.MESSAGE_ELEM); 
    445         Element dm_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext); 
     450      Document doc = XMLConverter.newDOM(); 
     451        Element dm_message = doc.createElement(GSXML.MESSAGE_ELEM); 
     452        Element dm_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext); 
    446453        dm_message.appendChild(dm_request); 
    447454 
     
    452459        meta_names.add("Date"); 
    453460 
    454         Element param_list = this.doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER); 
     461        Element param_list = doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER); 
    455462 
    456463        Element param = null; 
     
    459466        { 
    460467            String name = i.next(); 
    461             param = this.doc.createElement(GSXML.PARAM_ELEM); 
     468            param = doc.createElement(GSXML.PARAM_ELEM); 
    462469            param_list.appendChild(param); 
    463470            param.setAttribute(GSXML.NAME_ATT, "metadata"); 
     
    469476 
    470477        // create the doc node list for the metadata request 
    471         Element dm_doc_list = this.doc.createElement(GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER); 
     478        Element dm_doc_list = doc.createElement(GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER); 
    472479        dm_request.appendChild(dm_doc_list); 
    473480 
     
    475482        { 
    476483            // Add the documentNode to the list 
    477             Element dm_doc_node = this.doc.createElement(GSXML.DOC_NODE_ELEM); 
     484            Element dm_doc_node = doc.createElement(GSXML.DOC_NODE_ELEM); 
    478485            dm_doc_list.appendChild(dm_doc_node); 
    479486            dm_doc_node.setAttribute(GSXML.NODE_ID_ATT, ids.next()); 
     
    489496 
    490497        // Create a new (empty) result message 
    491         Element result = this.doc.createElement(GSXML.RESPONSE_ELEM); 
     498        Document result_doc = XMLConverter.newDOM(); 
     499        Element result = result_doc.createElement(GSXML.RESPONSE_ELEM); 
    492500 
    493501        Iterator<String> keys = docsMap.keySet().iterator(); 
     
    499507            Iterator itemItr = items.values().iterator(); 
    500508 
    501             Element collectionNode = this.doc.createElement("berryList"); 
     509            Element collectionNode = result_doc.createElement("berryList"); 
    502510            collectionNode.setAttribute("name", collection); 
    503511            result.appendChild(collectionNode); 
     
    506514            { 
    507515                Item item = (Item) itemItr.next(); 
    508                 Element itemElement = this.doc.createElement("item"); 
     516                Element itemElement = result_doc.createElement("item"); 
    509517 
    510518                collectionNode.appendChild(itemElement); 
     
    524532    { 
    525533        // Create a new (empty) result message 
    526         Element result = this.doc.createElement(GSXML.RESPONSE_ELEM); 
     534      Document result_doc = XMLConverter.newDOM(); 
     535        Element result = result_doc.createElement(GSXML.RESPONSE_ELEM); 
    527536 
    528537        // Get the parameters of the request 
     
    606615 
    607616            logger.info("\nMail was sent successfully."); 
    608             result.appendChild(this.doc.createTextNode("Mail was sent successfully.")); 
     617            result.appendChild(result_doc.createTextNode("Mail was sent successfully.")); 
    609618        } 
    610619        catch (Exception e) 
    611620        { 
    612621            e.printStackTrace(); 
    613             result.appendChild(this.doc.createTextNode(e.getMessage())); 
     622            result.appendChild(result_doc.createTextNode(e.getMessage())); 
    614623        } 
    615624 
     
    651660        } 
    652661 
    653         public Element wrapIntoElement() 
     662        public Element wrapIntoElement(Document doc) 
    654663        { 
    655664            Element itemElement = doc.createElement("item"); 
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/CoverageMetadataRetrieve.java

    r25976 r28966  
    6565        // with their names and service types 
    6666        // we have two services, a new textquery, and a new one of a new type 
    67         //Element tq_service = this.doc.createElement(GSXML.SERVICE_ELEM); 
     67        //Element tq_service = this.desc_doc.createElement(GSXML.SERVICE_ELEM); 
    6868        //tq_service.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_QUERY); 
    6969        //tq_service.setAttribute(GSXML.NAME_ATT, QUERY_SERVICE); 
    7070        //this.short_service_info.appendChild(tq_service); 
    7171 
    72         Element diff_service = this.doc.createElement(GSXML.SERVICE_ELEM); 
     72        Element diff_service = this.desc_doc.createElement(GSXML.SERVICE_ELEM); 
    7373        diff_service.setAttribute(GSXML.TYPE_ATT, "retrieve"); 
    7474        diff_service.setAttribute(GSXML.NAME_ATT, COVERAGE_SERVICE); 
     
    122122        if (format != null) 
    123123        { 
    124             this.format_info_map.put(COVERAGE_SERVICE, this.doc.importNode(format, true)); 
     124            this.format_info_map.put(COVERAGE_SERVICE, this.desc_doc.importNode(format, true)); 
    125125        } 
    126126 
     
    130130 
    131131    // get the desription of a service. Could include parameter lists, displayText 
    132     protected Element getServiceDescription(String service, String lang, String subset) 
     132  protected Element getServiceDescription(Document doc, String service, String lang, String subset) 
    133133    { 
    134134 
     
    141141        /* 
    142142         * if (service.equals(QUERY_SERVICE)) { Element tq_service = 
    143          * this.doc.createElement(GSXML.SERVICE_ELEM); 
     143         * doc.createElement(GSXML.SERVICE_ELEM); 
    144144         * tq_service.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_QUERY); 
    145145         * tq_service.setAttribute(GSXML.NAME_ATT, QUERY_SERVICE); if 
     
    148148         * in any <displayText> elements // name, for example - get from 
    149149         * properties file 
    150          * tq_service.appendChild(GSXML.createDisplayTextElement(this.doc, 
     150         * tq_service.appendChild(GSXML.createDisplayTextElement(doc, 
    151151         * GSXML.DISPLAY_TEXT_NAME, getTextString(QUERY_SERVICE+".name", lang) 
    152152         * )); } 
     
    155155         * subset.equals(GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER)) { // add in a 
    156156         * param list if this service has parameters Element param_list = 
    157          * this.doc.createElement(GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER); 
     157         * doc.createElement(GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER); 
    158158         * tq_service.appendChild(param_list); // create any params and append 
    159159         * to param_list } return tq_service; } 
     
    162162        if (service.equals(COVERAGE_SERVICE)) 
    163163        { 
    164             Element diff_service = this.doc.createElement(GSXML.SERVICE_ELEM); 
     164            Element diff_service = doc.createElement(GSXML.SERVICE_ELEM); 
    165165            diff_service.setAttribute(GSXML.TYPE_ATT, "retrieve"); 
    166166            diff_service.setAttribute(GSXML.NAME_ATT, COVERAGE_SERVICE); 
     
    169169                // add in any <displayText> elements 
    170170                // name, for example - get from properties file 
    171                 diff_service.appendChild(GSXML.createDisplayTextElement(this.doc, GSXML.DISPLAY_TEXT_NAME, getTextString(COVERAGE_SERVICE + ".name", lang))); 
     171                diff_service.appendChild(GSXML.createDisplayTextElement(doc, GSXML.DISPLAY_TEXT_NAME, getTextString(COVERAGE_SERVICE + ".name", lang))); 
    172172            } 
    173173 
     
    175175            { 
    176176                // add in a param list if this service has parameters 
    177                 Element param_list = this.doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER); 
     177                Element param_list = doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER); 
    178178                diff_service.appendChild(param_list); 
    179179                // create any params and append to param_list 
     
    230230 
    231231        // Create response 
    232         Element result = this.doc.createElement(GSXML.RESPONSE_ELEM); 
     232        Document result_doc = XMLConverter.newDOM(); 
     233        Element result = result_doc.createElement(GSXML.RESPONSE_ELEM); 
    233234        result.setAttribute(GSXML.FROM_ATT, COVERAGE_SERVICE); 
    234235        result.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_PROCESS); 
    235236 
    236         Element metadataSetList = this.doc.createElement("metadataSetList"); 
     237        Element metadataSetList = result_doc.createElement("metadataSetList"); 
    237238        result.appendChild(metadataSetList); 
    238239 
     
    249250 
    250251            // Create metadataSet using the current key and add to metadataSetList 
    251             metadataSet = this.doc.createElement("metadataSet"); 
     252            metadataSet = result_doc.createElement("metadataSet"); 
    252253            if (current_key.indexOf("-") != -1) 
    253254            { 
     
    263264            { 
    264265                value = iter2.next(); 
    265                 metadata = this.doc.createElement("metadata"); 
     266                metadata = result_doc.createElement("metadata"); 
    266267                metadata.setAttribute(GSXML.NAME_ATT, value); 
    267268                metadataSet.appendChild(metadata); 
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/CrossCollectionSearch.java

    r28180 r28966  
    2929import org.greenstone.gsdl3.util.GSXML; 
    3030import org.greenstone.gsdl3.util.UserContext; 
     31import org.greenstone.gsdl3.util.XMLConverter; 
     32 
     33import org.w3c.dom.Document; 
    3134import org.w3c.dom.Element; 
    3235import org.w3c.dom.Node; 
     
    6568        logger.info("Configuring CrossCollectionSearch..."); 
    6669        // query service 
    67         Element ccs_service = this.doc.createElement(GSXML.SERVICE_ELEM); 
     70        Element ccs_service = this.desc_doc.createElement(GSXML.SERVICE_ELEM); 
    6871        ccs_service.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_QUERY); 
    6972        ccs_service.setAttribute(GSXML.NAME_ATT, TEXT_QUERY_SERVICE); 
     
    7174 
    7275        // metadata service 
    73         Element dmr_service = this.doc.createElement(GSXML.SERVICE_ELEM); 
     76        Element dmr_service = this.desc_doc.createElement(GSXML.SERVICE_ELEM); 
    7477        dmr_service.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_RETRIEVE); 
    7578        dmr_service.setAttribute(GSXML.NAME_ATT, DOCUMENT_METADATA_RETRIEVE_SERVICE); 
     
    8083        if (format_info != null) 
    8184        { 
    82             this.format_info_map.put(TEXT_QUERY_SERVICE, this.doc.importNode(format_info, true)); 
     85            this.format_info_map.put(TEXT_QUERY_SERVICE, this.desc_doc.importNode(format_info, true)); 
    8386        } 
    8487        else 
     
    9194            } 
    9295            format_string += "</xsl:attribute><gsf:icon/></a></td><td><gsf:metadata name='Title'/> (<xsl:value-of select='@collection'/>) </td></gsf:template></format>"; 
    93             this.format_info_map.put(TEXT_QUERY_SERVICE, this.doc.importNode(this.converter.getDOM(format_string).getDocumentElement(), true)); 
     96            this.format_info_map.put(TEXT_QUERY_SERVICE, this.desc_doc.importNode(this.converter.getDOM(format_string).getDocumentElement(), true)); 
    9497        } 
    9598        return true; 
    9699    } 
    97100 
    98     protected Element getServiceDescription(String service, String lang, String subset) 
     101  protected Element getServiceDescription(Document doc, String service, String lang, String subset) 
    99102    { 
    100103        if (service.equals(TEXT_QUERY_SERVICE)) 
    101104        { 
    102105 
    103             Element ccs_service = this.doc.createElement(GSXML.SERVICE_ELEM); 
     106            Element ccs_service = doc.createElement(GSXML.SERVICE_ELEM); 
    104107            ccs_service.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_QUERY); 
    105108            ccs_service.setAttribute(GSXML.NAME_ATT, TEXT_QUERY_SERVICE); 
     
    108111            if (subset == null || subset.equals(GSXML.DISPLAY_TEXT_ELEM + GSXML.LIST_MODIFIER)) 
    109112            { 
    110                 ccs_service.appendChild(GSXML.createDisplayTextElement(this.doc, GSXML.DISPLAY_TEXT_NAME, getTextString(TEXT_QUERY_SERVICE + ".name", lang))); 
    111                 ccs_service.appendChild(GSXML.createDisplayTextElement(this.doc, GSXML.DISPLAY_TEXT_SUBMIT, getTextString(TEXT_QUERY_SERVICE + ".submit", lang))); 
    112                 ccs_service.appendChild(GSXML.createDisplayTextElement(this.doc, GSXML.DISPLAY_TEXT_DESCRIPTION, getTextString(TEXT_QUERY_SERVICE + ".description", lang))); 
     113                ccs_service.appendChild(GSXML.createDisplayTextElement(doc, GSXML.DISPLAY_TEXT_NAME, getTextString(TEXT_QUERY_SERVICE + ".name", lang))); 
     114                ccs_service.appendChild(GSXML.createDisplayTextElement(doc, GSXML.DISPLAY_TEXT_SUBMIT, getTextString(TEXT_QUERY_SERVICE + ".submit", lang))); 
     115                ccs_service.appendChild(GSXML.createDisplayTextElement(doc, GSXML.DISPLAY_TEXT_DESCRIPTION, getTextString(TEXT_QUERY_SERVICE + ".description", lang))); 
    113116            } 
    114117            // param info 
    115118            if (subset == null || subset.equals(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER)) 
    116119            { 
    117                 Element param_list = this.doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER); 
     120                Element param_list = doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER); 
    118121                // collection list 
    119122                if (coll_ids_list == null) 
     
    125128                    addCollectionNames(lang); 
    126129                } 
    127                 Element param = GSXML.createParameterDescription(this.doc, COLLECTION_PARAM, getTextString("param." + COLLECTION_PARAM, lang), GSXML.PARAM_TYPE_ENUM_MULTI, "all", coll_ids_list, coll_names_map.get(lang)); 
     130                Element param = GSXML.createParameterDescription(doc, COLLECTION_PARAM, getTextString("param." + COLLECTION_PARAM, lang), GSXML.PARAM_TYPE_ENUM_MULTI, "all", coll_ids_list, coll_names_map.get(lang)); 
    128131                param_list.appendChild(param); 
    129132                // query param 
    130                 param = GSXML.createParameterDescription(this.doc, QUERY_PARAM, getTextString("param." + QUERY_PARAM, lang), GSXML.PARAM_TYPE_STRING, null, null, null); 
     133                param = GSXML.createParameterDescription(doc, QUERY_PARAM, getTextString("param." + QUERY_PARAM, lang), GSXML.PARAM_TYPE_STRING, null, null, null); 
    131134                param_list.appendChild(param); 
    132135                ccs_service.appendChild(param_list); 
     
    137140        } 
    138141        // these ones are probably never called, but put them here just in case 
    139         Element service_elem = this.doc.createElement(GSXML.SERVICE_ELEM); 
     142        Element service_elem = doc.createElement(GSXML.SERVICE_ELEM); 
    140143        service_elem.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_RETRIEVE); 
    141144        service_elem.setAttribute(GSXML.NAME_ATT, service); 
     
    147150    { 
    148151        // Create a new (empty) result message 
    149         Element result = this.doc.createElement(GSXML.RESPONSE_ELEM); 
     152      Document result_doc = XMLConverter.newDOM(); 
     153        Element result = result_doc.createElement(GSXML.RESPONSE_ELEM); 
    150154        result.setAttribute(GSXML.FROM_ATT, TEXT_QUERY_SERVICE); 
    151155        result.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_PROCESS); 
     
    173177        } 
    174178 
    175         Element query_message = this.doc.createElement(GSXML.MESSAGE_ELEM); 
     179        Document msg_doc = XMLConverter.newDOM(); 
     180        Element query_message = msg_doc.createElement(GSXML.MESSAGE_ELEM); 
    176181        // we are sending the same request to each collection - build up the to 
    177182        // attribute for the request 
     
    187192        } 
    188193        // send the query to all colls 
    189         Element query_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to_att.toString(), userContext); 
     194        Element query_request = GSXML.createBasicRequest(msg_doc, GSXML.REQUEST_TYPE_PROCESS, to_att.toString(), userContext); 
    190195        query_message.appendChild(query_request); 
    191196        // should we add params individually? 
    192         Element new_param_list = this.doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER); 
     197        Element new_param_list = msg_doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER); 
    193198        query_request.appendChild(new_param_list); 
    194         new_param_list.appendChild(this.doc.importNode(GSXML.getNamedElement(param_list, GSXML.PARAM_ELEM, GSXML.NAME_ATT, QUERY_PARAM), true)); 
     199        new_param_list.appendChild(msg_doc.importNode(GSXML.getNamedElement(param_list, GSXML.PARAM_ELEM, GSXML.NAME_ATT, QUERY_PARAM), true)); 
    195200        Element query_result = (Element) this.router.process(query_message); 
    196201 
     
    215220        } 
    216221 
    217         Element metadata_list = this.doc.createElement(GSXML.METADATA_ELEM + GSXML.LIST_MODIFIER); 
     222        Element metadata_list = result_doc.createElement(GSXML.METADATA_ELEM + GSXML.LIST_MODIFIER); 
    218223        result.appendChild(metadata_list); 
    219         GSXML.addMetadata(this.doc, metadata_list, "numDocsReturned", "" + numDocsReturned); 
    220         //GSXML.addMetadata(this.doc, metadata_list, "numDocsMatched", ""+numDocsMatched); 
    221  
    222         Element doc_node_list = this.doc.createElement(GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER); 
     224        GSXML.addMetadata(metadata_list, "numDocsReturned", "" + numDocsReturned); 
     225        //GSXML.addMetadata(metadata_list, "numDocsMatched", ""+numDocsMatched); 
     226 
     227        Element doc_node_list = result_doc.createElement(GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER); 
    223228        result.appendChild(doc_node_list); 
    224229 
     
    240245                { 
    241246 
    242                     doc_node_list.appendChild(this.doc.importNode(this_node, true)); 
     247                    doc_node_list.appendChild(result_doc.importNode(this_node, true)); 
    243248                } 
    244249                else 
     
    267272 
    268273        // first, get the message router info 
    269         Element coll_list_message = this.doc.createElement(GSXML.MESSAGE_ELEM); 
    270         Element coll_list_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, "", userContext); // uid 
     274        Document msg_doc = XMLConverter.newDOM(); 
     275        Element coll_list_message = msg_doc.createElement(GSXML.MESSAGE_ELEM); 
     276        Element coll_list_request = GSXML.createBasicRequest(msg_doc, GSXML.REQUEST_TYPE_DESCRIBE, "", userContext); // uid 
    271277        coll_list_message.appendChild(coll_list_request); 
    272278        logger.debug("coll list request = " + this.converter.getPrettyString(coll_list_request)); 
     
    283289        NodeList colls = coll_list_response.getElementsByTagName(GSXML.COLLECTION_ELEM); 
    284290        // we can send the same request to multiple collections at once by using a comma separated list 
    285         Element metadata_message = this.doc.createElement(GSXML.MESSAGE_ELEM); 
     291        Element metadata_message = msg_doc.createElement(GSXML.MESSAGE_ELEM); 
    286292        StringBuffer colls_sb = new StringBuffer(); 
    287293        for (int i = 0; i < colls.getLength(); i++) 
     
    298304        } 
    299305 
    300         Element metadata_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, colls_sb.toString(), userContext); 
     306        Element metadata_request = GSXML.createBasicRequest(msg_doc, GSXML.REQUEST_TYPE_DESCRIBE, colls_sb.toString(), userContext); 
    301307        metadata_message.appendChild(metadata_request); 
    302308        logger.debug("metadata request = " + this.converter.getPrettyString(metadata_message)); 
     
    352358 
    353359        // need to request MR for collection descriptions 
    354         Element metadata_message = this.doc.createElement(GSXML.MESSAGE_ELEM); 
     360        Document msg_doc = XMLConverter.newDOM(); 
     361        Element metadata_message = msg_doc.createElement(GSXML.MESSAGE_ELEM); 
    355362 
    356363        // get a comma separated list of coll ids to send to MR 
     
    365372            colls_sb.append(coll_ids_list[i]); 
    366373        } 
    367         Element metadata_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, colls_sb.toString(), userContext); 
     374        Element metadata_request = GSXML.createBasicRequest(msg_doc, GSXML.REQUEST_TYPE_DESCRIBE, colls_sb.toString(), userContext); 
    368375        // param_list to request just displayTextList 
    369         Element param_list = this.doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER); 
    370         Element param = GSXML.createParameter(this.doc, GSXML.SUBSET_PARAM, GSXML.DISPLAY_TEXT_ELEM + GSXML.LIST_MODIFIER); 
     376        Element param_list = msg_doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER); 
     377        Element param = GSXML.createParameter(msg_doc, GSXML.SUBSET_PARAM, GSXML.DISPLAY_TEXT_ELEM + GSXML.LIST_MODIFIER); 
    371378        param_list.appendChild(param); 
    372379        metadata_request.appendChild(param_list); 
     
    393400    { 
    394401        // Create a new (empty) result message 
    395         Element result = this.doc.createElement(GSXML.RESPONSE_ELEM); 
     402      Document result_doc = XMLConverter.newDOM(); 
     403        Element result = result_doc.createElement(GSXML.RESPONSE_ELEM); 
    396404        result.setAttribute(GSXML.FROM_ATT, DOCUMENT_METADATA_RETRIEVE_SERVICE); 
    397405        result.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_PROCESS); 
     
    414422 
    415423        // the resulting doc node list 
    416         Element result_node_list = this.doc.createElement(GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER); 
     424        Element result_node_list = result_doc.createElement(GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER); 
    417425        result.appendChild(result_node_list); 
    418426 
    419         // get all the metadata params 
    420         Element new_param_list = this.doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER); 
    421         Element param = GSXML.createParameter(this.doc, "metadata", "Title"); 
    422         new_param_list.appendChild(param); 
    423427 
    424428        // organise the nodes into collection lists 
     
    432436            if (coll_items == null) 
    433437            { 
    434                 coll_items = this.doc.createElement(GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER); 
     438                coll_items = result_doc.createElement(GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER); 
    435439                coll_map.put(coll_name, coll_items); 
    436440            } 
    437             coll_items.appendChild(this.doc.importNode(doc_node, true)); 
     441            coll_items.appendChild(result_doc.importNode(doc_node, true)); 
    438442        } 
    439443 
    440444        // create teh individual requests 
    441         Element meta_request_message = this.doc.createElement(GSXML.MESSAGE_ELEM); 
     445        Document msg_doc = XMLConverter.newDOM(); 
     446        Element meta_request_message = msg_doc.createElement(GSXML.MESSAGE_ELEM); 
     447        // get all the metadata params 
     448        Element new_param_list = msg_doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER); 
     449        Element param = GSXML.createParameter(msg_doc, "metadata", "Title"); 
     450        new_param_list.appendChild(param); 
     451 
    442452        Set mapping_set = coll_map.entrySet(); 
    443453        Iterator iter = mapping_set.iterator(); 
     
    448458            String cname = (String) e.getKey(); 
    449459            Element doc_nodes = (Element) e.getValue(); 
    450             Element meta_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, GSPath.appendLink(cname, DOCUMENT_METADATA_RETRIEVE_SERVICE), userContext); 
    451             meta_request.appendChild(doc_nodes); 
     460            Element meta_request = GSXML.createBasicRequest(msg_doc, GSXML.REQUEST_TYPE_PROCESS, GSPath.appendLink(cname, DOCUMENT_METADATA_RETRIEVE_SERVICE), userContext); 
     461            meta_request.appendChild(msg_doc.importNode(doc_nodes, true)); 
    452462            meta_request.appendChild(new_param_list.cloneNode(true)); 
    453463            meta_request_message.appendChild(meta_request); 
     
    456466 
    457467        Node meta_result_node = this.router.process(meta_request_message); 
    458         Element meta_result = this.converter.nodeToElement(meta_result_node); 
     468        Element meta_result = GSXML.nodeToElement(meta_result_node); 
    459469 
    460470        // now need to put the doc nodes back in the right order 
     
    472482        { 
    473483            Element doc_node = (Element) query_doc_list.item(i); 
    474             Element new_node = (Element) this.doc.importNode(doc_node, false); 
     484            Element new_node = (Element) result_doc.importNode(doc_node, false); 
    475485            result_node_list.appendChild(new_node); 
    476486            String coll_name = doc_node.getAttribute("collection"); 
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/DebugService.java

    r28118 r28966  
    5252        for (int i = 0; i < services.length; i++) 
    5353        { 
    54             Element service = this.doc.createElement(GSXML.SERVICE_ELEM); 
     54            Element service = this.desc_doc.createElement(GSXML.SERVICE_ELEM); 
    5555            service.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_RETRIEVE); 
    5656            service.setAttribute(GSXML.NAME_ATT, services[i]); 
     
    6161    } 
    6262 
    63     protected Element getServiceDescription(String service_id, String lang, String subset) 
     63  protected Element getServiceDescription(Document doc, String service_id, String lang, String subset) 
    6464    { 
    6565        for (int i = 0; i < services.length; i++) 
     
    6767            if (service_id.equals(services[i])) 
    6868            { 
    69                 Element service_elem = this.doc.createElement(GSXML.SERVICE_ELEM); 
     69                Element service_elem = doc.createElement(GSXML.SERVICE_ELEM); 
    7070                service_elem.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_RETRIEVE); 
    7171                service_elem.setAttribute(GSXML.NAME_ATT, services[i]); 
     
    7979    protected Element processResolveCallTemplate(Element request) 
    8080    { 
    81         Element result = GSXML.createBasicResponse(this.doc, RESOLVE_CALL_TEMPLATE); 
     81        Document result_doc = XMLConverter.newDOM(); 
     82 
     83        Element result = GSXML.createBasicResponse(result_doc, RESOLVE_CALL_TEMPLATE); 
    8284 
    8385        if (request == null) 
    8486        { 
    85             GSXML.addError(this.doc, result, RESOLVE_CALL_TEMPLATE + ": Request is null", GSXML.ERROR_TYPE_SYNTAX); 
     87            GSXML.addError(result, RESOLVE_CALL_TEMPLATE + ": Request is null", GSXML.ERROR_TYPE_SYNTAX); 
    8688            return result; 
    8789        } 
     
    99101        if (!found) 
    100102        { 
    101             GSXML.addError(this.doc, result, "This user does not have the required permissions to perform this action."); 
     103            GSXML.addError(result, "This user does not have the required permissions to perform this action."); 
    102104            return result; 
    103105        } 
     
    108110        if (param_list == null) 
    109111        { 
    110             GSXML.addError(this.doc, result, RESOLVE_CALL_TEMPLATE + ": No param list specified", GSXML.ERROR_TYPE_SYNTAX); 
     112            GSXML.addError(result, RESOLVE_CALL_TEMPLATE + ": No param list specified", GSXML.ERROR_TYPE_SYNTAX); 
    111113            return result; 
    112114        } 
     
    142144                Element debugElement = (Element) current.getElementsByTagName("debug").item(0); 
    143145 
    144                 Element requestedTemplate = this.doc.createElement("requestedTemplate"); 
     146                Element requestedTemplate = result_doc.createElement("requestedTemplate"); 
    145147                requestedTemplate.setTextContent(debugElement.getAttribute("filename")); 
    146148                result.appendChild(requestedTemplate); 
     
    153155    protected Element processGetXMLTemplateFromFile(Element request) 
    154156    { 
    155         Element result = GSXML.createBasicResponse(this.doc, GET_TEMPLATE_FROM_XML_FILE); 
     157      Document result_doc = XMLConverter.newDOM(); 
     158        Element result = GSXML.createBasicResponse(result_doc, GET_TEMPLATE_FROM_XML_FILE); 
    156159 
    157160        if (request == null) 
    158161        { 
    159             GSXML.addError(this.doc, result, GET_TEMPLATE_FROM_XML_FILE + ": Request is null", GSXML.ERROR_TYPE_SYNTAX); 
     162            GSXML.addError(result, GET_TEMPLATE_FROM_XML_FILE + ": Request is null", GSXML.ERROR_TYPE_SYNTAX); 
    160163            return result; 
    161164        } 
     
    173176        if (!found) 
    174177        { 
    175             GSXML.addError(this.doc, result, "This user does not have the required permissions to perform this action."); 
     178            GSXML.addError(result, "This user does not have the required permissions to perform this action."); 
    176179            return result; 
    177180        } 
     
    182185        if (param_list == null) 
    183186        { 
    184             GSXML.addError(this.doc, result, GET_TEMPLATE_FROM_XML_FILE + ": No param list specified", GSXML.ERROR_TYPE_SYNTAX); 
     187            GSXML.addError(result, GET_TEMPLATE_FROM_XML_FILE + ": No param list specified", GSXML.ERROR_TYPE_SYNTAX); 
    185188            return result; 
    186189        } 
     
    210213        else 
    211214        { 
    212             GSXML.addError(this.doc, result, "A valid namespace was not specified."); 
     215            GSXML.addError(result, "A valid namespace was not specified."); 
    213216            return result; 
    214217        } 
     
    257260                        fixAttributes(template); 
    258261 
    259                         Element requestedTemplate = this.doc.createElement("requestedNameTemplate"); 
    260                         requestedTemplate.appendChild(this.doc.importNode(template, true)); 
     262                        Element requestedTemplate = result_doc.createElement("requestedNameTemplate"); 
     263                        requestedTemplate.appendChild(result_doc.importNode(template, true)); 
    261264                        result.appendChild(requestedTemplate); 
    262265                    } 
     
    274277                        fixAttributes(template); 
    275278 
    276                         Element requestedTemplate = this.doc.createElement("requestedMatchTemplate"); 
    277                         requestedTemplate.appendChild(this.doc.importNode(template, true)); 
     279                        Element requestedTemplate = result_doc.createElement("requestedMatchTemplate"); 
     280                        requestedTemplate.appendChild(result_doc.importNode(template, true)); 
    278281                        result.appendChild(requestedTemplate); 
    279282                    } 
     
    306309    protected Element processSaveXMLTemplateToFile(Element request) 
    307310    { 
    308         Element result = GSXML.createBasicResponse(this.doc, SAVE_TEMPLATE_TO_XML_FILE); 
     311      Document result_doc = XMLConverter.newDOM(); 
     312        Element result = GSXML.createBasicResponse(result_doc, SAVE_TEMPLATE_TO_XML_FILE); 
    309313 
    310314        if (request == null) 
    311315        { 
    312             GSXML.addError(this.doc, result, SAVE_TEMPLATE_TO_XML_FILE + ": Request is null", GSXML.ERROR_TYPE_SYNTAX); 
     316            GSXML.addError(result, SAVE_TEMPLATE_TO_XML_FILE + ": Request is null", GSXML.ERROR_TYPE_SYNTAX); 
    313317            return result; 
    314318        } 
     
    326330        if (!foundGroup) 
    327331        { 
    328             GSXML.addError(this.doc, result, "This user does not have the required permissions to perform this action."); 
     332            GSXML.addError(result, "This user does not have the required permissions to perform this action."); 
    329333            return result; 
    330334        } 
     
    335339        if (param_list == null) 
    336340        { 
    337             GSXML.addError(this.doc, result, SAVE_TEMPLATE_TO_XML_FILE + ": No param list specified", GSXML.ERROR_TYPE_SYNTAX); 
     341            GSXML.addError(result, SAVE_TEMPLATE_TO_XML_FILE + ": No param list specified", GSXML.ERROR_TYPE_SYNTAX); 
    338342            return result; 
    339343        } 
     
    364368        else 
    365369        { 
    366             GSXML.addError(this.doc, result, SAVE_TEMPLATE_TO_XML_FILE + ": The specified namespace was not valid", GSXML.ERROR_TYPE_SYNTAX); 
     370            GSXML.addError(result, SAVE_TEMPLATE_TO_XML_FILE + ": The specified namespace was not valid", GSXML.ERROR_TYPE_SYNTAX); 
    367371            return result; 
    368372        } 
     
    441445            if (!found) 
    442446            { 
    443                 GSXML.addError(this.doc, result, SAVE_TEMPLATE_TO_XML_FILE + ": Could not save as the specified template could not be found", GSXML.ERROR_TYPE_SYNTAX); 
     447                GSXML.addError(result, SAVE_TEMPLATE_TO_XML_FILE + ": Could not save as the specified template could not be found", GSXML.ERROR_TYPE_SYNTAX); 
    444448            } 
    445449            else 
     
    457461                catch (Exception ex) 
    458462                { 
    459                     GSXML.addError(this.doc, result, SAVE_TEMPLATE_TO_XML_FILE + ": There was an error writing out the XML file", GSXML.ERROR_TYPE_SYNTAX); 
     463                    GSXML.addError(result, SAVE_TEMPLATE_TO_XML_FILE + ": There was an error writing out the XML file", GSXML.ERROR_TYPE_SYNTAX); 
    460464                } 
    461465 
     
    464468        else 
    465469        { 
    466             GSXML.addError(this.doc, result, SAVE_TEMPLATE_TO_XML_FILE + "File: " + xslFile.getAbsolutePath() + " does not exist", GSXML.ERROR_TYPE_SYNTAX); 
     470            GSXML.addError(result, SAVE_TEMPLATE_TO_XML_FILE + "File: " + xslFile.getAbsolutePath() + " does not exist", GSXML.ERROR_TYPE_SYNTAX); 
    467471        } 
    468472 
     
    472476    protected Element processGetTemplateListFromFile(Element request) 
    473477    { 
    474         Element result = GSXML.createBasicResponse(this.doc, GET_TEMPLATE_LIST_FROM_FILE); 
     478      Document result_doc = XMLConverter.newDOM(); 
     479        Element result = GSXML.createBasicResponse(result_doc, GET_TEMPLATE_LIST_FROM_FILE); 
    475480 
    476481        if (request == null) 
    477482        { 
    478             GSXML.addError(this.doc, result, GET_TEMPLATE_LIST_FROM_FILE + ": Request is null", GSXML.ERROR_TYPE_SYNTAX); 
     483            GSXML.addError(result, GET_TEMPLATE_LIST_FROM_FILE + ": Request is null", GSXML.ERROR_TYPE_SYNTAX); 
    479484            return result; 
    480485        } 
     
    492497        if (!found) 
    493498        { 
    494             GSXML.addError(this.doc, result, "This user does not have the required permissions to perform this action."); 
     499            GSXML.addError(result, "This user does not have the required permissions to perform this action."); 
    495500            return result; 
    496501        } 
     
    501506        if (param_list == null) 
    502507        { 
    503             GSXML.addError(this.doc, result, GET_TEMPLATE_FROM_XML_FILE + ": No param list specified", GSXML.ERROR_TYPE_SYNTAX); 
     508            GSXML.addError(result, GET_TEMPLATE_FROM_XML_FILE + ": No param list specified", GSXML.ERROR_TYPE_SYNTAX); 
    504509            return result; 
    505510        } 
     
    517522        if (locationName == null || locationName.length() == 0) 
    518523        { 
    519             GSXML.addError(this.doc, result, "Parameter \"locationName\" was null or empty."); 
     524            GSXML.addError(result, "Parameter \"locationName\" was null or empty."); 
    520525            return result; 
    521526        } 
     
    534539            } 
    535540 
    536             Element templateList = this.doc.createElement("templateList"); 
     541            Element templateList = result_doc.createElement("templateList"); 
    537542            StringBuilder templateListString = new StringBuilder("["); 
    538543 
     
    574579        else 
    575580        { 
    576             GSXML.addError(this.doc, result, "File: " + xslFile.getAbsolutePath() + " does not exist"); 
     581            GSXML.addError(result, "File: " + xslFile.getAbsolutePath() + " does not exist"); 
    577582            return result; 
    578583        } 
     
    583588    protected Element processGetXSLTFilesForCollection(Element request) 
    584589    { 
    585         Element result = GSXML.createBasicResponse(this.doc, GET_XSLT_FILES_FOR_COLLECTION); 
     590      Document result_doc = XMLConverter.newDOM(); 
     591        Element result = GSXML.createBasicResponse(result_doc, GET_XSLT_FILES_FOR_COLLECTION); 
    586592 
    587593        if (request == null) 
    588594        { 
    589             GSXML.addError(this.doc, result, GET_XSLT_FILES_FOR_COLLECTION + ": Request is null", GSXML.ERROR_TYPE_SYNTAX); 
     595            GSXML.addError(result, GET_XSLT_FILES_FOR_COLLECTION + ": Request is null", GSXML.ERROR_TYPE_SYNTAX); 
    590596            return result; 
    591597        } 
     
    603609        if (!found) 
    604610        { 
    605             GSXML.addError(this.doc, result, "This user does not have the required permissions to perform this action."); 
     611            GSXML.addError(result, "This user does not have the required permissions to perform this action."); 
    606612            return result; 
    607613        } 
     
    612618        if (param_list == null) 
    613619        { 
    614             GSXML.addError(this.doc, result, GET_TEMPLATE_FROM_XML_FILE + ": No param list specified", GSXML.ERROR_TYPE_SYNTAX); 
     620            GSXML.addError(result, GET_TEMPLATE_FROM_XML_FILE + ": No param list specified", GSXML.ERROR_TYPE_SYNTAX); 
    615621            return result; 
    616622        } 
     
    622628        String collectionName = (String) params.get("collectionName"); 
    623629 
    624         Element fileList = this.doc.createElement("fileListJSON"); 
     630        Element fileList = result_doc.createElement("fileListJSON"); 
    625631        StringBuilder fileListString = new StringBuilder("["); 
    626632 
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/DocXMLUtil.java

    r24993 r28966  
    2525import org.greenstone.gsdl3.util.GSXML; 
    2626import org.greenstone.gsdl3.util.UserContext; 
     27import org.greenstone.gsdl3.util.XMLConverter; 
    2728 
    2829import org.w3c.dom.Document; 
     
    8283        for (int i = 0; i < services.length; i++) 
    8384        { 
    84             Element service = this.doc.createElement(GSXML.SERVICE_ELEM); 
     85            Element service = this.desc_doc.createElement(GSXML.SERVICE_ELEM); 
    8586            service.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_RETRIEVE); 
    8687            service.setAttribute(GSXML.NAME_ATT, services[i]); 
     
    8889        } 
    8990         
    90         _GSDM = new GSDocumentModel(this.site_home, this.doc, this.router); 
     91        _GSDM = new GSDocumentModel(this.site_home, this.router); 
    9192 
    9293        return true; 
    9394    } 
    9495 
    95     protected Element getServiceDescription(String service_id, String lang, String subset) 
     96  protected Element getServiceDescription(Document doc, String service_id, String lang, String subset) 
    9697    { 
    9798        for (int i = 0; i < services.length; i++) 
     
    99100            if (service_id.equals(services[i])) 
    100101            { 
    101                 Element service_elem = this.doc.createElement(GSXML.SERVICE_ELEM); 
     102                Element service_elem = doc.createElement(GSXML.SERVICE_ELEM); 
    102103                service_elem.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_RETRIEVE); 
    103104                service_elem.setAttribute(GSXML.NAME_ATT, services[i]); 
     
    115116    protected Element processDocXMLCreateEmptyFile(Element request) 
    116117    { 
    117         Element result = GSXML.createBasicResponse(this.doc, DOC_XML_CREATE_EMPTY_FILE); 
    118  
    119         if (request == null) 
    120         { 
    121             GSXML.addError(this.doc, result, DOC_XML_CREATE_EMPTY_FILE + ": Request is null", GSXML.ERROR_TYPE_SYNTAX); 
     118      Document result_doc = XMLConverter.newDOM(); 
     119        Element result = GSXML.createBasicResponse(result_doc, DOC_XML_CREATE_EMPTY_FILE); 
     120 
     121        if (request == null) 
     122        { 
     123            GSXML.addError(result, DOC_XML_CREATE_EMPTY_FILE + ": Request is null", GSXML.ERROR_TYPE_SYNTAX); 
    122124            return result; 
    123125        } 
     
    144146    protected Element processDocXMLGetMetadata(Element request) 
    145147    { 
    146         Element result = GSXML.createBasicResponse(this.doc, DOC_XML_GET_METADATA); 
    147  
    148         if (request == null) 
    149         { 
    150             GSXML.addError(this.doc, result, DOC_XML_GET_METADATA + ": Request is null", GSXML.ERROR_TYPE_SYNTAX); 
     148      Document result_doc = XMLConverter.newDOM(); 
     149        Element result = GSXML.createBasicResponse(result_doc, DOC_XML_GET_METADATA); 
     150 
     151        if (request == null) 
     152        { 
     153            GSXML.addError(result, DOC_XML_GET_METADATA + ": Request is null", GSXML.ERROR_TYPE_SYNTAX); 
    151154            return result; 
    152155        } 
     
    171174            for(Element metadataValue : metadataValues) 
    172175            { 
    173                 Element metadataElem = this.doc.createElement(GSXML.METADATA_ELEM); 
     176                Element metadataElem = result_doc.createElement(GSXML.METADATA_ELEM); 
    174177                metadataElem.setAttribute(GSXML.NAME_ATT, metadataName); 
    175178                metadataElem.setAttribute(GSXML.VALUE_ATT, metadataValue.getFirstChild().getNodeValue()); 
     
    183186    protected Element processDocXMLSetMetadata(Element request) 
    184187    { 
    185         Element result = GSXML.createBasicResponse(this.doc, DOC_XML_SET_METADATA); 
    186  
    187         if (request == null) 
    188         { 
    189             GSXML.addError(this.doc, result, DOC_XML_SET_METADATA + ": Request is null", GSXML.ERROR_TYPE_SYNTAX); 
     188      Document result_doc = XMLConverter.newDOM(); 
     189        Element result = GSXML.createBasicResponse(result_doc, DOC_XML_SET_METADATA); 
     190 
     191        if (request == null) 
     192        { 
     193            GSXML.addError(result, DOC_XML_SET_METADATA + ": Request is null", GSXML.ERROR_TYPE_SYNTAX); 
    190194            return result; 
    191195        } 
     
    232236                catch(Exception ex) 
    233237                { 
    234                     GSXML.addError(this.doc, result, DOC_XML_SET_METADATA + ": Error converting the position attribute to an integer", GSXML.ERROR_TYPE_SYNTAX); 
     238                    GSXML.addError(result, DOC_XML_SET_METADATA + ": Error converting the position attribute to an integer", GSXML.ERROR_TYPE_SYNTAX); 
    235239                    return result; 
    236240                } 
     
    252256            else 
    253257            { 
    254                 GSXML.addError(this.doc, result, DOC_XML_SET_METADATA + ": A position or previous value was not given", GSXML.ERROR_TYPE_SYNTAX); 
     258                GSXML.addError(result, DOC_XML_SET_METADATA + ": A position or previous value was not given", GSXML.ERROR_TYPE_SYNTAX); 
    255259                return result; 
    256260            } 
     
    262266    protected Element processDocXMLCreateSection(Element request) 
    263267    { 
    264         Element result = GSXML.createBasicResponse(this.doc, DOC_XML_CREATE_SECTION); 
    265  
    266         if (request == null) 
    267         { 
    268             GSXML.addError(this.doc, result, DOC_XML_CREATE_SECTION + ": Request is null", GSXML.ERROR_TYPE_SYNTAX); 
     268      Document result_doc = XMLConverter.newDOM(); 
     269        Element result = GSXML.createBasicResponse(result_doc, DOC_XML_CREATE_SECTION); 
     270 
     271        if (request == null) 
     272        { 
     273            GSXML.addError(result, DOC_XML_CREATE_SECTION + ": Request is null", GSXML.ERROR_TYPE_SYNTAX); 
    269274            return result; 
    270275        } 
     
    291296    protected Element processDocXMLDeleteSection(Element request) 
    292297    { 
    293         Element result = GSXML.createBasicResponse(this.doc, DOC_XML_DELETE_SECTION); 
    294  
    295         if (request == null) 
    296         { 
    297             GSXML.addError(this.doc, result, DOC_XML_DELETE_SECTION + ": Request is null", GSXML.ERROR_TYPE_SYNTAX); 
     298      Document result_doc = XMLConverter.newDOM(); 
     299        Element result = GSXML.createBasicResponse(result_doc, DOC_XML_DELETE_SECTION); 
     300 
     301        if (request == null) 
     302        { 
     303            GSXML.addError(result, DOC_XML_DELETE_SECTION + ": Request is null", GSXML.ERROR_TYPE_SYNTAX); 
    298304            return result; 
    299305        } 
     
    320326    protected Element processDocXMLGetSection(Element request) 
    321327    { 
    322         Element result = GSXML.createBasicResponse(this.doc, DOC_XML_GET_SECTION); 
    323  
    324         if (request == null) 
    325         { 
    326             GSXML.addError(this.doc, result, DOC_XML_GET_SECTION + ": Request is null", GSXML.ERROR_TYPE_SYNTAX); 
     328      Document result_doc = XMLConverter.newDOM(); 
     329        Element result = GSXML.createBasicResponse(result_doc, DOC_XML_GET_SECTION); 
     330 
     331        if (request == null) 
     332        { 
     333            GSXML.addError(result, DOC_XML_GET_SECTION + ": Request is null", GSXML.ERROR_TYPE_SYNTAX); 
    327334            return result; 
    328335        } 
     
    349356    protected Element processDocXMLSetSection(Element request) 
    350357    { 
    351         Element result = GSXML.createBasicResponse(this.doc, DOC_XML_SET_SECTION); 
    352  
    353         if (request == null) 
    354         { 
    355             GSXML.addError(this.doc, result, DOC_XML_SET_SECTION + ": Request is null", GSXML.ERROR_TYPE_SYNTAX); 
     358      Document result_doc = XMLConverter.newDOM(); 
     359        Element result = GSXML.createBasicResponse(result_doc, DOC_XML_SET_SECTION); 
     360 
     361        if (request == null) 
     362        { 
     363            GSXML.addError(result, DOC_XML_SET_SECTION + ": Request is null", GSXML.ERROR_TYPE_SYNTAX); 
    356364            return result; 
    357365        } 
     
    394402    protected Element processDocXMLGetText(Element request) 
    395403    { 
    396         Element result = GSXML.createBasicResponse(this.doc, DOC_XML_GET_TEXT); 
    397  
    398         if (request == null) 
    399         { 
    400             GSXML.addError(this.doc, result, DOC_XML_GET_TEXT + ": Request is null", GSXML.ERROR_TYPE_SYNTAX); 
     404      Document result_doc = XMLConverter.newDOM(); 
     405        Element result = GSXML.createBasicResponse(result_doc, DOC_XML_GET_TEXT); 
     406 
     407        if (request == null) 
     408        { 
     409            GSXML.addError(result, DOC_XML_GET_TEXT + ": Request is null", GSXML.ERROR_TYPE_SYNTAX); 
    401410            return result; 
    402411        } 
     
    420429            if (content == null) 
    421430            { 
    422                 result.appendChild(this.doc.createElement(GSXML.DOCXML_CONTENT_ELEM)); 
     431                result.appendChild(result_doc.createElement(GSXML.DOCXML_CONTENT_ELEM)); 
    423432            } 
    424433            else 
    425434            { 
    426                 Element contentElem = this.doc.createElement(GSXML.DOCXML_CONTENT_ELEM); 
    427                 Node textNode = this.doc.createTextNode(content); 
     435                Element contentElem = result_doc.createElement(GSXML.DOCXML_CONTENT_ELEM); 
     436                Node textNode = result_doc.createTextNode(content); 
    428437                contentElem.appendChild(textNode); 
    429438                result.appendChild(contentElem);  
     
    436445    protected Element processDocXMLSetText(Element request) 
    437446    { 
    438         Element result = GSXML.createBasicResponse(this.doc, DOC_XML_SET_TEXT); 
    439  
    440         if (request == null) 
    441         { 
    442             GSXML.addError(this.doc, result, DOC_XML_SET_TEXT + ": Request is null", GSXML.ERROR_TYPE_SYNTAX); 
     447      Document result_doc = XMLConverter.newDOM(); 
     448        Element result = GSXML.createBasicResponse(result_doc, DOC_XML_SET_TEXT); 
     449 
     450        if (request == null) 
     451        { 
     452            GSXML.addError(result, DOC_XML_SET_TEXT + ": Request is null", GSXML.ERROR_TYPE_SYNTAX); 
    443453            return result; 
    444454        } 
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/DocumentBasket.java

    r25635 r28966  
    2727import java.util.Iterator; 
    2828 
     29import org.w3c.dom.Document; 
    2930import org.w3c.dom.Element; 
    3031import org.w3c.dom.NodeList; 
     
    3536import org.greenstone.gsdl3.util.GSPath; 
    3637import org.greenstone.gsdl3.util.UserContext; 
     38import org.greenstone.gsdl3.util.XMLConverter; 
    3739 
    3840import java.net.InetAddress; 
     
    115117 
    116118        // set up short_service_info_ - for now just has name and type 
    117         Element add_service = this.doc.createElement(GSXML.SERVICE_ELEM); 
     119        Element add_service = this.desc_doc.createElement(GSXML.SERVICE_ELEM); 
    118120        add_service.setAttribute(GSXML.TYPE_ATT, "gather"); // what?? 
    119121        add_service.setAttribute(GSXML.NAME_ATT, ADD_ITEM_SERVICE); 
     
    121123 
    122124        // set up short_service_info_ - for now just has name and type 
    123         Element disp_service = this.doc.createElement(GSXML.SERVICE_ELEM); 
     125        Element disp_service = this.desc_doc.createElement(GSXML.SERVICE_ELEM); 
    124126        disp_service.setAttribute(GSXML.TYPE_ATT, "gather"); // what?? 
    125127        disp_service.setAttribute(GSXML.NAME_ATT, DISPLAY_ITEMS_SERVICE); 
     
    127129 
    128130        // set up short_service_info_ - for now just has name and type 
    129         Element num_service = this.doc.createElement(GSXML.SERVICE_ELEM); 
     131        Element num_service = this.desc_doc.createElement(GSXML.SERVICE_ELEM); 
    130132        num_service.setAttribute(GSXML.TYPE_ATT, "gather"); // what?? 
    131133        num_service.setAttribute(GSXML.NAME_ATT, ITEM_NUM_SERVICE); 
     
    133135 
    134136        // set up short_service_info_ - for now just has name and type 
    135         Element delete_service = this.doc.createElement(GSXML.SERVICE_ELEM); 
     137        Element delete_service = this.desc_doc.createElement(GSXML.SERVICE_ELEM); 
    136138        delete_service.setAttribute(GSXML.TYPE_ATT, "gather"); // what?? 
    137139        delete_service.setAttribute(GSXML.NAME_ATT, DELETE_ITEMS_SERVICE); 
     
    139141 
    140142        // set up short_service_info_ - for now just has name and type 
    141         Element deleteone_service = this.doc.createElement(GSXML.SERVICE_ELEM); 
     143        Element deleteone_service = this.desc_doc.createElement(GSXML.SERVICE_ELEM); 
    142144        deleteone_service.setAttribute(GSXML.TYPE_ATT, "gather"); // what?? 
    143145        deleteone_service.setAttribute(GSXML.NAME_ATT, DELETE_ITEM_SERVICE); 
     
    145147         
    146148        // set up short_service_info_ - for now just has name and type 
    147         Element deleteall_service = this.doc.createElement(GSXML.SERVICE_ELEM); 
     149        Element deleteall_service = this.desc_doc.createElement(GSXML.SERVICE_ELEM); 
    148150        deleteall_service.setAttribute(GSXML.TYPE_ATT, "gather"); // what?? 
    149151        deleteall_service.setAttribute(GSXML.NAME_ATT, CLEAR_ITEMS_SERVICE); 
     
    151153 
    152154        // set up short_service_info_ - for now just has name and type 
    153         Element merge_service = this.doc.createElement(GSXML.SERVICE_ELEM); 
     155        Element merge_service = this.desc_doc.createElement(GSXML.SERVICE_ELEM); 
    154156        merge_service.setAttribute(GSXML.TYPE_ATT, "gather"); // what?? 
    155157        merge_service.setAttribute(GSXML.NAME_ATT, MERGE_ITEM_SERVICE); 
     
    160162 
    161163    /** returns a specific service description */ 
    162     protected Element getServiceDescription(String service_id, String lang, String subset) 
     164  protected Element getServiceDescription(Document doc, String service_id, String lang, String subset) 
    163165    { 
    164166        if (service_id.equals(ADD_ITEM_SERVICE)) 
    165167        { 
    166             Element add_service = this.doc.createElement(GSXML.SERVICE_ELEM); 
     168            Element add_service = doc.createElement(GSXML.SERVICE_ELEM); 
    167169            add_service.setAttribute(GSXML.TYPE_ATT, "gather"); // what?? 
    168170            add_service.setAttribute(GSXML.NAME_ATT, ADD_ITEM_SERVICE); 
     
    172174        { 
    173175 
    174             Element disp_service = this.doc.createElement(GSXML.SERVICE_ELEM); 
     176            Element disp_service = doc.createElement(GSXML.SERVICE_ELEM); 
    175177            disp_service.setAttribute(GSXML.TYPE_ATT, "gather"); // what?? 
    176178            disp_service.setAttribute(GSXML.NAME_ATT, DISPLAY_ITEMS_SERVICE); 
     
    181183        { 
    182184 
    183             Element num_service = this.doc.createElement(GSXML.SERVICE_ELEM); 
     185            Element num_service = doc.createElement(GSXML.SERVICE_ELEM); 
    184186            num_service.setAttribute(GSXML.TYPE_ATT, "gather"); // what?? 
    185187            num_service.setAttribute(GSXML.NAME_ATT, ITEM_NUM_SERVICE); 
     
    190192        { 
    191193 
    192             Element del_service = this.doc.createElement(GSXML.SERVICE_ELEM); 
     194            Element del_service = doc.createElement(GSXML.SERVICE_ELEM); 
    193195            del_service.setAttribute(GSXML.TYPE_ATT, "gather"); // what?? 
    194196            del_service.setAttribute(GSXML.NAME_ATT, DELETE_ITEMS_SERVICE); 
     
    199201        { 
    200202 
    201             Element clear_service = this.doc.createElement(GSXML.SERVICE_ELEM); 
     203            Element clear_service = doc.createElement(GSXML.SERVICE_ELEM); 
    202204            clear_service.setAttribute(GSXML.TYPE_ATT, "gather"); // what?? 
    203205            clear_service.setAttribute(GSXML.NAME_ATT, CLEAR_ITEMS_SERVICE); 
     
    208210        { 
    209211 
    210             Element delone_service = this.doc.createElement(GSXML.SERVICE_ELEM); 
     212            Element delone_service = doc.createElement(GSXML.SERVICE_ELEM); 
    211213            delone_service.setAttribute(GSXML.TYPE_ATT, "gather"); // what?? 
    212214            delone_service.setAttribute(GSXML.NAME_ATT, DELETE_ITEM_SERVICE); 
     
    215217        if (service_id.equals(MERGE_ITEM_SERVICE)) 
    216218        { 
    217             Element merge_service = this.doc.createElement(GSXML.SERVICE_ELEM); 
     219            Element merge_service = doc.createElement(GSXML.SERVICE_ELEM); 
    218220            merge_service.setAttribute(GSXML.TYPE_ATT, "gather"); // what?? 
    219221            merge_service.setAttribute(GSXML.NAME_ATT, MERGE_ITEM_SERVICE); 
     
    229231        //System.err.println("DOCSMAP = " + docsMap); 
    230232        // Create a new (empty) result message 
    231         Element result = this.doc.createElement(GSXML.RESPONSE_ELEM); 
     233        Document result_doc = XMLConverter.newDOM(); 
     234        Element result = result_doc.createElement(GSXML.RESPONSE_ELEM); 
    232235 
    233236        // Get the parameters of the request 
     
    261264                Item newItem = generateItem(collection, item); 
    262265                items.put(item, newItem); 
    263                 result.appendChild(newItem.wrapIntoElement()); 
     266                result.appendChild(newItem.wrapIntoElement(result_doc)); 
    264267            } 
    265268        } 
     
    270273            items.put(item, newItem); 
    271274            docsMap.put(collection, items); 
    272             result.appendChild(newItem.wrapIntoElement()); 
     275            result.appendChild(newItem.wrapIntoElement(result_doc)); 
    273276        } 
    274277 
     
    423426    { 
    424427        Hashtable<String, Hashtable<String, Item>> docsMap = updateDocMap(request); 
    425          
    426         Element result = this.doc.createElement(GSXML.RESPONSE_ELEM); 
     428        Document result_doc = XMLConverter.newDOM(); 
     429        Element result = result_doc.createElement(GSXML.RESPONSE_ELEM); 
    427430         
    428431        // Get the parameters of the request 
     
    451454 
    452455        // Create a new (empty) result message 
    453         Element result = this.doc.createElement(GSXML.RESPONSE_ELEM); 
     456        Document result_doc = XMLConverter.newDOM(); 
     457        Element result = result_doc.createElement(GSXML.RESPONSE_ELEM); 
    454458 
    455459        // Get the parameters of the request 
     
    509513 
    510514        // Create a new (empty) result message 
    511         Element result = this.doc.createElement(GSXML.RESPONSE_ELEM); 
     515        Document result_doc = XMLConverter.newDOM(); 
     516        Element result = result_doc.createElement(GSXML.RESPONSE_ELEM); 
    512517 
    513518        // Get the parameters of the request 
     
    560565 
    561566        // Create a new (empty) result message 
    562         Element result = this.doc.createElement(GSXML.RESPONSE_ELEM); 
     567        Document result_doc = XMLConverter.newDOM(); 
     568        Element result = result_doc.createElement(GSXML.RESPONSE_ELEM); 
    563569 
    564570        int size = 0; 
     
    574580            { 
    575581                Item item = (Item) values.next(); 
    576                 result.appendChild(item.wrapIntoElement()); 
    577             } 
    578         } 
    579  
    580         Element selement = this.doc.createElement("size"); 
     582                result.appendChild(item.wrapIntoElement(result_doc)); 
     583            } 
     584        } 
     585 
     586        Element selement = result_doc.createElement("size"); 
    581587        selement.setAttribute("value", size + ""); 
    582588        result.appendChild(selement); 
     
    585591    } 
    586592 
    587     private Element getDocumentMetadata(String to, UserContext userContext, Iterator<String> ids) 
     593  private Element getDocumentMetadata(String to, UserContext userContext, Iterator<String> ids) 
    588594    { 
    589595 
    590596        // Build a request to obtain some document metadata 
    591         Element dm_message = this.doc.createElement(GSXML.MESSAGE_ELEM); 
    592         Element dm_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext); 
     597      Document msg_doc = XMLConverter.newDOM(); 
     598        Element dm_message = msg_doc.createElement(GSXML.MESSAGE_ELEM); 
     599        Element dm_request = GSXML.createBasicRequest(msg_doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext); 
    593600        dm_message.appendChild(dm_request); 
    594601 
     
    599606        meta_names.add("Date"); 
    600607 
    601         Element param_list = this.doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER); 
     608        Element param_list = msg_doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER); 
    602609 
    603610        Element param = null; 
     
    606613        { 
    607614            String name = i.next(); 
    608             param = this.doc.createElement(GSXML.PARAM_ELEM); 
     615            param = msg_doc.createElement(GSXML.PARAM_ELEM); 
    609616            param_list.appendChild(param); 
    610617            param.setAttribute(GSXML.NAME_ATT, "metadata"); 
     
    615622 
    616623        // create the doc node list for the metadata request 
    617         Element dm_doc_list = this.doc.createElement(GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER); 
     624        Element dm_doc_list = msg_doc.createElement(GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER); 
    618625        dm_request.appendChild(dm_doc_list); 
    619626 
     
    621628        { 
    622629            // Add the documentNode to the list 
    623             Element dm_doc_node = this.doc.createElement(GSXML.DOC_NODE_ELEM); 
     630            Element dm_doc_node = msg_doc.createElement(GSXML.DOC_NODE_ELEM); 
    624631            dm_doc_list.appendChild(dm_doc_node); 
    625632            dm_doc_node.setAttribute(GSXML.NODE_ID_ATT, ids.next()); 
     
    634641 
    635642        // Create a new (empty) result message 
    636         Element result = this.doc.createElement(GSXML.RESPONSE_ELEM); 
     643        Document result_doc = XMLConverter.newDOM(); 
     644        Element result = result_doc.createElement(GSXML.RESPONSE_ELEM); 
    637645 
    638646        Iterator<String> keys = docsMap.keySet().iterator(); 
     
    644652            Iterator itemItr = items.values().iterator(); 
    645653 
    646             Element collectionNode = this.doc.createElement("documentList"); 
     654            Element collectionNode = result_doc.createElement("documentList"); 
    647655            collectionNode.setAttribute("name", collection); 
    648656            result.appendChild(collectionNode); 
     
    651659            { 
    652660                Item item = (Item) itemItr.next(); 
    653                 Element itemElement = this.doc.createElement("item"); 
     661                Element itemElement = result_doc.createElement("item"); 
    654662 
    655663                collectionNode.appendChild(itemElement); 
     
    698706        } 
    699707 
    700         public Element wrapIntoElement() 
     708        public Element wrapIntoElement(Document doc) 
    701709        { 
    702710            Element itemElement = doc.createElement("item"); 
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/DocumentMaker.java

    r25895 r28966  
    4040import org.greenstone.gsdl3.util.GSXML; 
    4141import org.greenstone.gsdl3.util.UserContext; 
    42  
     42import org.greenstone.gsdl3.util.XMLConverter; 
     43 
     44import org.w3c.dom.Document; 
    4345import org.w3c.dom.Element; 
    4446import org.w3c.dom.NodeList; 
     
    8486        for (int i = 0; i < services.length; i++) 
    8587        { 
    86             Element service = this.doc.createElement(GSXML.SERVICE_ELEM); 
     88            Element service = this.desc_doc.createElement(GSXML.SERVICE_ELEM); 
    8789            service.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_RETRIEVE); 
    8890            service.setAttribute(GSXML.NAME_ATT, services[i]); 
     
    9092        } 
    9193 
    92         _GSDM = new GSDocumentModel(this.site_home, this.doc, this.router); 
     94        _GSDM = new GSDocumentModel(this.site_home, this.router); 
    9395 
    9496        return true; 
    9597    } 
    9698 
    97     protected Element getServiceDescription(String service_id, String lang, String subset) 
     99  protected Element getServiceDescription(Document doc, String service_id, String lang, String subset) 
    98100    { 
    99101        for (int i = 0; i < services.length; i++) 
     
    101103            if (service_id.equals(services[i])) 
    102104            { 
    103                 Element service_elem = this.doc.createElement(GSXML.SERVICE_ELEM); 
     105                Element service_elem = doc.createElement(GSXML.SERVICE_ELEM); 
    104106                service_elem.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_RETRIEVE); 
    105107                service_elem.setAttribute(GSXML.NAME_ATT, services[i]); 
     
    117119    protected Element processDocumentCreate(Element request) 
    118120    { 
    119         Element result = GSXML.createBasicResponse(this.doc, DOCUMENT_CREATE); 
    120  
    121         if (request == null) 
    122         { 
    123             GSXML.addError(this.doc, result, DOCUMENT_CREATE + ": Request is null", GSXML.ERROR_TYPE_SYNTAX); 
     121      Document result_doc = XMLConverter.newDOM(); 
     122        Element result = GSXML.createBasicResponse(result_doc, DOCUMENT_CREATE); 
     123 
     124        if (request == null) 
     125        { 
     126            GSXML.addError(result, DOCUMENT_CREATE + ": Request is null", GSXML.ERROR_TYPE_SYNTAX); 
    124127            return result; 
    125128        } 
     
    148151    protected Element processDocumentDelete(Element request) 
    149152    { 
    150         Element result = GSXML.createBasicResponse(this.doc, DOCUMENT_DELETE); 
    151  
    152         if (request == null) 
    153         { 
    154             GSXML.addError(this.doc, result, DOCUMENT_DELETE + ": Request is null", GSXML.ERROR_TYPE_SYNTAX); 
     153      Document result_doc = XMLConverter.newDOM(); 
     154        Element result = GSXML.createBasicResponse(result_doc, DOCUMENT_DELETE); 
     155 
     156        if (request == null) 
     157        { 
     158            GSXML.addError(result, DOCUMENT_DELETE + ": Request is null", GSXML.ERROR_TYPE_SYNTAX); 
    155159            return result; 
    156160        } 
     
    178182    protected Element processDocumentDuplicate(Element request) 
    179183    { 
    180         Element result = GSXML.createBasicResponse(this.doc, DOCUMENT_DUPLICATE); 
    181  
    182         if (request == null)