Changeset 28382


Ignore:
Timestamp:
10/10/13 17:21:30 (7 years ago)
Author:
davidb
Message:

Elimination of the 'this.doc' field from the Action baseclass and the subclasses that rely on it. For Greenstone3 purposes it is unsafe to create this object in the constructor to the action and then store it for other methods to access. This is because the Greenstone 3 (and in particular calls to 'process' operate in a multi-threaded context, that is managed by the Servlet server (e.g. Tomcat by default). Calls to DOM methods are not guaranteed to be thread safe, this became apparent when we started looking in to an exception that was being thrown, and centred around use of the DOM method 'item(i)'. The change this commit makes is to remove 'this.doc' being stored as a field. A document is now created in the top level of a call to 'process()' and when a DOM reference is needed in a subsequent method an Element variable (typically passed in as a parameter to the method) is used (through 'Document doc = element.getOwnerDocument()') to gain access to the DOM

Location:
main/trunk/greenstone3/src/java/org/greenstone/gsdl3
Files:
16 edited

Legend:

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

    r27998 r28382  
    2424    /** the system set up variables */
    2525    protected HashMap<String, Object> config_params = null;
    26     /** container Document to create XML Nodes */
    27     protected Document doc = null;
     26   
     27   
    2828    /** a converter class to parse XML and create Docs */
    2929    protected XMLConverter converter = null;
     
    3939    {
    4040        this.converter = new XMLConverter();
    41         this.doc = this.converter.newDOM();
    4241    }
    4342
     
    193192    }
    194193
    195     protected Element createMetadataParamList(HashSet<String> metadata_names)
    196     {
    197         Element param_list = this.doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
     194    protected Element createMetadataParamList(Document doc, HashSet<String> metadata_names)
     195    {
     196        Element param_list = doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
    198197
    199198        Element param = null;
     
    202201        {
    203202            String name = i.next();
    204             param = this.doc.createElement(GSXML.PARAM_ELEM);
     203            param = doc.createElement(GSXML.PARAM_ELEM);
    205204            param_list.appendChild(param);
    206205            param.setAttribute(GSXML.NAME_ATT, "metadata");
     
    240239    protected void addSiteMetadata(Element element, UserContext userContext)
    241240    {
     241        Document doc = element.getOwnerDocument();
     242       
    242243        //ADD SITE METADATA
    243         Element metadata_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, "", userContext);
     244        Element metadata_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_DESCRIBE, "", userContext);
    244245        //create a hashmap of params
    245246        HashMap subset_params = new HashMap(1);
    246247        subset_params.put(GSXML.SUBSET_PARAM, GSXML.METADATA_ELEM + GSXML.LIST_MODIFIER);
    247248        //create the element to put the params in
    248         Element param_list = this.doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
     249        Element param_list = doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
    249250        //put them in
    250         GSXML.addParametersToList(this.doc, param_list, subset_params);
     251        GSXML.addParametersToList(doc, param_list, subset_params);
    251252        metadata_request.appendChild(param_list);
    252253        //create the message
    253         Element metadata_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
     254        Element metadata_message = doc.createElement(GSXML.MESSAGE_ELEM);
    254255        metadata_message.appendChild(metadata_request);
    255256        //get response
     
    263264    protected void addInterfaceOptions(Element elem)
    264265    {
    265         Element documentOptionList = this.doc.createElement("interfaceOptions");
     266        Document doc = elem.getOwnerDocument();
     267       
     268        Element documentOptionList = doc.createElement("interfaceOptions");
    266269        for (Object key : this.config_params.keySet())
    267270        {
    268             Element option = this.doc.createElement("option");
     271            Element option = doc.createElement("option");
    269272            option.setAttribute(GSXML.NAME_ATT, (String) key);
    270273            option.setAttribute(GSXML.VALUE_ATT, this.config_params.get(key).toString());
     
    276279    protected Element getFormatInfo(String to, UserContext userContext)
    277280    {
    278         Element mr_format_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
    279         Element mr_format_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_FORMAT, to, userContext);
     281        // Eclipse call hierarchy shows the element returned from this method is
     282        // subsequently used in a 'importNode'.  For this reason it is safe here
     283        // for call up our own document DOM. 
     284        //
     285        // If this pattern changes for any reason, then the DOM will need to be
     286        // passed in as a parameter
     287       
     288        Document doc = this.converter.newDOM();
     289       
     290        Element mr_format_message = doc.createElement(GSXML.MESSAGE_ELEM);
     291        Element mr_format_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_FORMAT, to, userContext);
    280292        mr_format_message.appendChild(mr_format_request);
    281293
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/AppletAction.java

    r26133 r28382  
    2525
    2626        Element message = this.converter.nodeToElement(message_node);
    27 
     27        Document doc = message.getOwnerDocument();
     28       
    2829        Element request = (Element) GSXML.getChildByTagName(message, GSXML.REQUEST_ELEM);
    29         Element result = this.doc.createElement(GSXML.MESSAGE_ELEM);
    30         Element page_response = this.doc.createElement(GSXML.RESPONSE_ELEM);
     30        Element result = doc.createElement(GSXML.MESSAGE_ELEM);
     31        Element page_response = doc.createElement(GSXML.RESPONSE_ELEM);
    3132        result.appendChild(page_response);
    3233
     
    6263            // we are processing stuff for the applet send a message to the service, type="query", and take out the something element, and return that as our result - the applet must take xml
    6364
    64             Element mr_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
    65             Element mr_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
     65            Element mr_message = doc.createElement(GSXML.MESSAGE_ELEM);
     66            Element mr_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
    6667            mr_message.appendChild(mr_request);
    6768            // just append all the params for now - should filter out unneeded ones
    68             mr_request.appendChild(this.doc.importNode(cgi_param_list, true));
     69            mr_request.appendChild(doc.importNode(cgi_param_list, true));
    6970
    7071            // process the request
     
    8081        // get the applet description, and the collection info if a collection is specified
    8182
    82         Element mr_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
    83         Element applet_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, to, userContext);
     83        Element mr_message = doc.createElement(GSXML.MESSAGE_ELEM);
     84        Element applet_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_DESCRIBE, to, userContext);
    8485        mr_message.appendChild(applet_request);
    8586
     
    8990        String path = GSPath.appendLink(GSXML.RESPONSE_ELEM, GSXML.SERVICE_ELEM);
    9091        //path = GSPath.appendLink(path, GSXML.APPLET_ELEM);
    91         Element service_elem = (Element) this.doc.importNode(GSXML.getNodeByPath(mr_response, path), true);
     92        Element service_elem = (Element) doc.importNode(GSXML.getNodeByPath(mr_response, path), true);
    9293        Element applet_elem = (Element) GSXML.getChildByTagName(service_elem, GSXML.APPLET_ELEM);
    9394        // must handle any params that have values that are not
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/BrowseAction.java

    r26026 r28382  
    1212import org.greenstone.gsdl3.util.OID;
    1313import org.greenstone.gsdl3.util.UserContext;
     14import org.w3c.dom.Document;
    1415import org.w3c.dom.Element;
    1516import org.w3c.dom.Node;
     
    2930    public Node process(Node message_node)
    3031    {
    31 
    3232        Element message = this.converter.nodeToElement(message_node);
    33 
     33        Document doc = message.getOwnerDocument();
     34       
    3435        // get the request - assume only one
    3536        Element request = (Element) GSXML.getChildByTagName(message, GSXML.REQUEST_ELEM);
    3637
    3738        // the result
    38         Element result = this.doc.createElement(GSXML.MESSAGE_ELEM);
     39        Element result = doc.createElement(GSXML.MESSAGE_ELEM);
    3940        Element response = classifierBrowse(request);
    4041        result.appendChild(response);
     
    4445    protected Element classifierBrowse(Element request)
    4546    {
    46 
    47         Element page_response = this.doc.createElement(GSXML.RESPONSE_ELEM);
     47        Document doc = request.getOwnerDocument();
     48       
     49        Element page_response = doc.createElement(GSXML.RESPONSE_ELEM);
    4850
    4951        // extract the params from the cgi-request, and check that we have a coll specified
     
    7577        // this should be cached somehow later on.
    7678
    77         Element info_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
    78         Element info_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, to, userContext);
     79        Element info_message = doc.createElement(GSXML.MESSAGE_ELEM);
     80        Element info_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_DESCRIBE, to, userContext);
    7981        info_message.appendChild(info_request);
    8082
    8183        // also get the format stuff now if there is some
    82         Element format_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_FORMAT, to, userContext);
     84        Element format_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_FORMAT, to, userContext);
    8385        info_message.appendChild(format_request);
    8486        // process the requests
     
    9294
    9395        Element service_description = (Element) GSXML.getChildByTagName(service_response, GSXML.SERVICE_ELEM);
    94         page_response.appendChild(this.doc.importNode(service_description, true));
     96        page_response.appendChild(doc.importNode(service_description, true));
    9597
    9698        //append site metadata
     
    137139                    GSXSLT.mergeFormatElements(this_format, global_format_elem, false);
    138140                }
    139                 Element new_format = GSXML.duplicateWithNewName(this.doc, this_format, GSXML.FORMAT_ELEM, false);
     141                Element new_format = GSXML.duplicateWithNewName(doc, this_format, GSXML.FORMAT_ELEM, false);
    140142                // set teh format type
    141143                new_format.setAttribute(GSXML.TYPE_ATT, "browse");
     
    158160        logger.info("extracted meta names, " + metadata_names.toString());
    159161        // get the browse structure for the selected node
    160         Element classify_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
    161         Element classify_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
     162        Element classify_message = doc.createElement(GSXML.MESSAGE_ELEM);
     163        Element classify_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
    162164        classify_message.appendChild(classify_request);
    163165
    164166        //Create a parameter list to specify the required structure information
    165167        // for now, always get ancestors and children
    166         Element param_list = this.doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
     168        Element param_list = doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
    167169        classify_request.appendChild(param_list);
    168         Element param = this.doc.createElement(GSXML.PARAM_ELEM);
     170        Element param = doc.createElement(GSXML.PARAM_ELEM);
    169171        param_list.appendChild(param);
    170172        param.setAttribute(GSXML.NAME_ATT, "structure");
    171173        param.setAttribute(GSXML.VALUE_ATT, "ancestors");
    172         param = this.doc.createElement(GSXML.PARAM_ELEM);
     174        param = doc.createElement(GSXML.PARAM_ELEM);
    173175        param_list.appendChild(param);
    174176        param.setAttribute(GSXML.NAME_ATT, "structure");
     
    176178        if (get_siblings)
    177179        {
    178             param = this.doc.createElement(GSXML.PARAM_ELEM);
     180            param = doc.createElement(GSXML.PARAM_ELEM);
    179181            param_list.appendChild(param);
    180182            param.setAttribute(GSXML.NAME_ATT, "structure");
     
    183185
    184186        // put the classifier node into a classifier node list
    185         Element classifier_list = this.doc.createElement(GSXML.CLASS_NODE_ELEM + GSXML.LIST_MODIFIER);
    186         Element classifier = this.doc.createElement(GSXML.CLASS_NODE_ELEM);
     187        Element classifier_list = doc.createElement(GSXML.CLASS_NODE_ELEM + GSXML.LIST_MODIFIER);
     188        Element classifier = doc.createElement(GSXML.CLASS_NODE_ELEM);
    187189        classifier.setAttribute(GSXML.NODE_ID_ATT, classifier_node);
    188190        classifier_list.appendChild(classifier);
     
    205207
    206208        // add the classifier node as the page classifier
    207         Element page_classifier = GSXML.duplicateWithNewName(this.doc, cl_structure, GSXML.CLASSIFIER_ELEM, true);
     209        Element page_classifier = GSXML.duplicateWithNewName(doc, cl_structure, GSXML.CLASSIFIER_ELEM, true);
    208210        page_response.appendChild(page_classifier);
    209211        page_classifier.setAttribute(GSXML.NAME_ATT, top_id);
     
    212214        // then for each document node
    213215
    214         Element metadata_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
     216        Element metadata_message = doc.createElement(GSXML.MESSAGE_ELEM);
    215217
    216218        boolean did_classifier = false;
     
    225227        {
    226228            did_classifier = true;
    227             Element cl_meta_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to + "MetadataRetrieve", userContext);
     229            Element cl_meta_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_PROCESS, to + "MetadataRetrieve", userContext);
    228230            metadata_message.appendChild(cl_meta_request);
    229231
    230             Element new_cl_nodes_list = this.doc.createElement(GSXML.CLASS_NODE_ELEM + GSXML.LIST_MODIFIER);
     232            Element new_cl_nodes_list = doc.createElement(GSXML.CLASS_NODE_ELEM + GSXML.LIST_MODIFIER);
    231233            cl_meta_request.appendChild(new_cl_nodes_list);
    232234
     
    234236            {
    235237
    236                 Element cl = this.doc.createElement(GSXML.CLASS_NODE_ELEM);
     238                Element cl = doc.createElement(GSXML.CLASS_NODE_ELEM);
    237239                cl.setAttribute(GSXML.NODE_ID_ATT, ((Element) cl_nodes.item(c)).getAttribute(GSXML.NODE_ID_ATT));
    238240                new_cl_nodes_list.appendChild(cl);
     
    245247            if (metadata_names.isEmpty())
    246248            {
    247                 cl_param_list = this.doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
    248                 Element p = this.doc.createElement(GSXML.PARAM_ELEM);
     249                cl_param_list = doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
     250                Element p = doc.createElement(GSXML.PARAM_ELEM);
    249251                cl_param_list.appendChild(p);
    250252                p.setAttribute(GSXML.NAME_ATT, "metadata");
     
    253255            else
    254256            {
    255                 cl_param_list = createMetadataParamList(metadata_names);
     257                cl_param_list = createMetadataParamList(doc,metadata_names);
    256258            }
    257259
     
    267269        {
    268270            did_documents = true;
    269             Element doc_meta_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, GSPath.appendLink(collection, "DocumentMetadataRetrieve"), userContext);
     271            Element doc_meta_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_PROCESS, GSPath.appendLink(collection, "DocumentMetadataRetrieve"), userContext);
    270272            metadata_message.appendChild(doc_meta_request);
    271273
    272             Element doc_list = this.doc.createElement(GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER);
     274            Element doc_list = doc.createElement(GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER);
    273275            doc_meta_request.appendChild(doc_list);
    274276
     
    276278            {
    277279
    278                 Element d = this.doc.createElement(GSXML.DOC_NODE_ELEM);
     280                Element d = doc.createElement(GSXML.DOC_NODE_ELEM);
    279281                d.setAttribute(GSXML.NODE_ID_ATT, ((Element) doc_nodes.item(c)).getAttribute(GSXML.NODE_ID_ATT));
    280282                doc_list.appendChild(d);
     
    282284
    283285            // create and add in the param list - add all for now
    284             Element doc_param_list = this.doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
    285             Element p = this.doc.createElement(GSXML.PARAM_ELEM);
     286            Element doc_param_list = doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
     287            Element p = doc.createElement(GSXML.PARAM_ELEM);
    286288            doc_param_list.appendChild(p);
    287289            p.setAttribute(GSXML.NAME_ATT, "metadata");
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/DepositorAction.java

    r28202 r28382  
    4343    {
    4444        Element request = (Element) GSXML.getChildByTagName(message, GSXML.REQUEST_ELEM);
    45 
     45        Document doc = request.getOwnerDocument();
     46       
    4647        UserContext uc = new UserContext((Element) request);
    4748        String currentUsername = uc.getUsername();
    4849
    49         Element responseMessage = this.doc.createElement(GSXML.MESSAGE_ELEM);
    50         Element response = GSXML.createBasicResponse(this.doc, this.getClass().getSimpleName());
     50        Element responseMessage = doc.createElement(GSXML.MESSAGE_ELEM);
     51        Element response = GSXML.createBasicResponse(doc, this.getClass().getSimpleName());
    5152        responseMessage.appendChild(response);
    5253
     
    226227            formContainer.appendChild(callToPage);
    227228
    228             Element cachedValueElement = this.doc.createElement("cachedValues");
     229            Element cachedValueElement = doc.createElement("cachedValues");
    229230            response.appendChild(cachedValueElement);
    230231            try
     
    232233                for (int i = pageNum; i > 0; i--)
    233234                {
    234                     Element page = this.doc.createElement("pageCache");
     235                    Element page = doc.createElement("pageCache");
    235236                    page.setAttribute("pageNum", "" + i);
    236237                    String cachedValues = database.getUserData(currentUsername, "DE___" + collection + "___" + i + "___CACHED_VALUES");
    237238                    if (cachedValues != null)
    238239                    {
    239                         page.appendChild(this.doc.createTextNode(cachedValues));
     240                        page.appendChild(doc.createTextNode(cachedValues));
    240241                        cachedValueElement.appendChild(page);
    241242                    }
     
    287288                {
    288289                    ex.printStackTrace();
    289                     GSXML.addError(this.doc, responseMessage, "Failed to copy the deposited file into the collection.");
     290                    GSXML.addError(doc, responseMessage, "Failed to copy the deposited file into the collection.");
    290291                    return responseMessage;
    291292                }
     
    331332                }
    332333
    333                 Element buildMessage = this.doc.createElement(GSXML.MESSAGE_ELEM);
    334                 Element buildRequest = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, "ImportCollection", uc);
     334                Element buildMessage = doc.createElement(GSXML.MESSAGE_ELEM);
     335                Element buildRequest = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_PROCESS, "ImportCollection", uc);
    335336                buildMessage.appendChild(buildRequest);
    336337
    337                 Element paramListElem = this.doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
     338                Element paramListElem = doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
    338339                buildRequest.appendChild(paramListElem);
    339340
    340                 Element collectionParam = this.doc.createElement(GSXML.PARAM_ELEM);
     341                Element collectionParam = doc.createElement(GSXML.PARAM_ELEM);
    341342                paramListElem.appendChild(collectionParam);
    342343                collectionParam.setAttribute(GSXML.NAME_ATT, GSXML.COLLECTION_ATT);
    343344                collectionParam.setAttribute(GSXML.VALUE_ATT, collection);
    344345
    345                 Element documentsParam = this.doc.createElement(GSXML.PARAM_ELEM);
     346                Element documentsParam = doc.createElement(GSXML.PARAM_ELEM);
    346347                paramListElem.appendChild(documentsParam);
    347348                documentsParam.setAttribute(GSXML.NAME_ATT, "documents");
     
    350351                Element buildResponseMessage = (Element) this.mr.process(buildMessage);
    351352
    352                 response.appendChild(this.doc.importNode(buildResponseMessage, true));
     353                response.appendChild(doc.importNode(buildResponseMessage, true));
    353354            }
    354355        }
     
    364365        else
    365366        {
    366             Element depositorPage = this.doc.createElement("depositorPage");
     367            Element depositorPage = doc.createElement("depositorPage");
    367368            response.appendChild(depositorPage);
    368369
    369             Element collList = getCollectionsInSite();
    370             depositorPage.appendChild(this.doc.importNode(collList, true));
     370            Element collList = getCollectionsInSite(doc);
     371            depositorPage.appendChild(doc.importNode(collList, true));
    371372        }
    372373
     
    374375    }
    375376
    376     public Element getCollectionsInSite()
     377    public Element getCollectionsInSite(Document doc)
    377378    {
    378         Element message = this.doc.createElement(GSXML.MESSAGE_ELEM);
    379         Element request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, "", new UserContext());
     379        Element message = doc.createElement(GSXML.MESSAGE_ELEM);
     380        Element request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_DESCRIBE, "", new UserContext());
    380381        message.appendChild(request);
    381382        Element responseMessage = (Element) this.mr.process(message);
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/DocumentAction.java

    r28258 r28382  
    8282
    8383        Element message = this.converter.nodeToElement(message_node);
    84 
     84        Document doc = message.getOwnerDocument();
     85       
    8586        // the response
    86         Element result = this.doc.createElement(GSXML.MESSAGE_ELEM);
    87         Element page_response = this.doc.createElement(GSXML.RESPONSE_ELEM);
     87        Element result = doc.createElement(GSXML.MESSAGE_ELEM);
     88        Element page_response = doc.createElement(GSXML.RESPONSE_ELEM);
    8889        result.appendChild(page_response);
    8990
     
    174175        // the_document is where all the doc info - structure and metadata etc
    175176        // is added into, to be returned in the page
    176         Element the_document = this.doc.createElement(GSXML.DOCUMENT_ELEM);
     177        Element the_document = doc.createElement(GSXML.DOCUMENT_ELEM);
    177178        page_response.appendChild(the_document);
    178179
    179180        // create a basic doc list containing the current node
    180         Element basic_doc_list = this.doc.createElement(GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER);
    181         Element current_doc = this.doc.createElement(GSXML.DOC_NODE_ELEM);
     181        Element basic_doc_list = doc.createElement(GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER);
     182        Element current_doc = doc.createElement(GSXML.DOC_NODE_ELEM);
    182183        basic_doc_list.appendChild(current_doc);
    183184        if (document_id != null)
     
    207208
    208209        // Create a parameter list to specify the required structure information
    209         Element ds_param_list = this.doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
     210        Element ds_param_list = doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
    210211
    211212        if (service_params != null)
    212213        {
    213             GSXML.addParametersToList(this.doc, ds_param_list, service_params);
     214            GSXML.addParametersToList(doc, ds_param_list, service_params);
    214215        }
    215216
     
    223224            if (expand_contents)
    224225            {
    225                 ds_param = this.doc.createElement(GSXML.PARAM_ELEM);
     226                ds_param = doc.createElement(GSXML.PARAM_ELEM);
    226227                ds_param_list.appendChild(ds_param);
    227228                ds_param.setAttribute(GSXML.NAME_ATT, "structure");
     
    230231
    231232            // get the info needed for paged naviagtion
    232             ds_param = this.doc.createElement(GSXML.PARAM_ELEM);
     233            ds_param = doc.createElement(GSXML.PARAM_ELEM);
    233234            ds_param_list.appendChild(ds_param);
    234235            ds_param.setAttribute(GSXML.NAME_ATT, "info");
    235236            ds_param.setAttribute(GSXML.VALUE_ATT, "numSiblings");
    236             ds_param = this.doc.createElement(GSXML.PARAM_ELEM);
     237            ds_param = doc.createElement(GSXML.PARAM_ELEM);
    237238            ds_param_list.appendChild(ds_param);
    238239            ds_param.setAttribute(GSXML.NAME_ATT, "info");
    239240            ds_param.setAttribute(GSXML.VALUE_ATT, "numChildren");
    240             ds_param = this.doc.createElement(GSXML.PARAM_ELEM);
     241            ds_param = doc.createElement(GSXML.PARAM_ELEM);
    241242            ds_param_list.appendChild(ds_param);
    242243            ds_param.setAttribute(GSXML.NAME_ATT, "info");
     
    245246            if (get_siblings)
    246247            {
    247                 ds_param = this.doc.createElement(GSXML.PARAM_ELEM);
     248                ds_param = doc.createElement(GSXML.PARAM_ELEM);
    248249                ds_param_list.appendChild(ds_param);
    249250                ds_param.setAttribute(GSXML.NAME_ATT, "structure");
     
    257258            if (expand_contents)
    258259            {
    259                 ds_param = this.doc.createElement(GSXML.PARAM_ELEM);
     260                ds_param = doc.createElement(GSXML.PARAM_ELEM);
    260261                ds_param_list.appendChild(ds_param);
    261262                ds_param.setAttribute(GSXML.NAME_ATT, "structure");
     
    265266            {
    266267                // get the info needed for table of contents
    267                 ds_param = this.doc.createElement(GSXML.PARAM_ELEM);
     268                ds_param = doc.createElement(GSXML.PARAM_ELEM);
    268269                ds_param_list.appendChild(ds_param);
    269270                ds_param.setAttribute(GSXML.NAME_ATT, "structure");
    270271                ds_param.setAttribute(GSXML.VALUE_ATT, "ancestors");
    271                 ds_param = this.doc.createElement(GSXML.PARAM_ELEM);
     272                ds_param = doc.createElement(GSXML.PARAM_ELEM);
    272273                ds_param_list.appendChild(ds_param);
    273274                ds_param.setAttribute(GSXML.NAME_ATT, "structure");
     
    275276                if (get_siblings)
    276277                {
    277                     ds_param = this.doc.createElement(GSXML.PARAM_ELEM);
     278                    ds_param = doc.createElement(GSXML.PARAM_ELEM);
    278279                    ds_param_list.appendChild(ds_param);
    279280                    ds_param.setAttribute(GSXML.NAME_ATT, "structure");
     
    292293
    293294            // Build a request to obtain the document structure
    294             Element ds_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
     295            Element ds_message = doc.createElement(GSXML.MESSAGE_ELEM);
    295296            String to = GSPath.appendLink(collection, "DocumentStructureRetrieve");// Hard-wired?
    296             Element ds_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
     297            Element ds_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
    297298            ds_message.appendChild(ds_request);
    298299            ds_request.appendChild(ds_param_list);
     
    316317            if (ds_response_struct_info != null)
    317318            {
    318                 the_document.appendChild(this.doc.importNode(ds_response_struct_info, true));
     319                the_document.appendChild(doc.importNode(ds_response_struct_info, true));
    319320            }
    320321            path = GSPath.appendLink(GSXML.RESPONSE_ELEM, GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER);
     
    329330                for (int i = 0; i < structs.getLength(); i++)
    330331                {
    331                     the_document.appendChild(this.doc.importNode(structs.item(i), true));
     332                    the_document.appendChild(doc.importNode(structs.item(i), true));
    332333                }
    333334            }
     
    335336            {
    336337                // no structure nodes, so put in a dummy doc node
    337                 Element doc_node = this.doc.createElement(GSXML.DOC_NODE_ELEM);
     338                Element doc_node = doc.createElement(GSXML.DOC_NODE_ELEM);
    338339                if (document_id != null)
    339340                {
     
    353354            // should think about this more
    354355            // no structure request, so just put in a dummy doc node
    355             Element doc_node = this.doc.createElement(GSXML.DOC_NODE_ELEM);
     356            Element doc_node = doc.createElement(GSXML.DOC_NODE_ELEM);
    356357            if (document_id != null)
    357358            {
     
    367368
    368369        // Build a request to obtain some document metadata
    369         Element dm_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
     370        Element dm_message = doc.createElement(GSXML.MESSAGE_ELEM);
    370371        String to = GSPath.appendLink(collection, "DocumentMetadataRetrieve"); // Hard-wired?
    371         Element dm_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
     372        Element dm_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
    372373        dm_message.appendChild(dm_request);
    373374        // Create a parameter list to specify the required metadata information
     
    390391        }
    391392
    392         Element dm_param_list = createMetadataParamList(meta_names);
     393        Element dm_param_list = createMetadataParamList(doc,meta_names);
    393394        if (service_params != null)
    394395        {
    395             GSXML.addParametersToList(this.doc, dm_param_list, service_params);
     396            GSXML.addParametersToList(doc, dm_param_list, service_params);
    396397        }
    397398
     
    399400
    400401        // create the doc node list for the metadata request
    401         Element dm_doc_list = this.doc.createElement(GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER);
     402        Element dm_doc_list = doc.createElement(GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER);
    402403        dm_request.appendChild(dm_doc_list);
    403404
     
    410411
    411412            // Add the documentNode to the list
    412             Element dm_doc_node = this.doc.createElement(GSXML.DOC_NODE_ELEM);
     413            Element dm_doc_node = doc.createElement(GSXML.DOC_NODE_ELEM);
    413414            dm_doc_list.appendChild(dm_doc_node);
    414415            dm_doc_node.setAttribute(GSXML.NODE_ID_ATT, doc_node_id);
     
    418419        // we also want a metadata request to the top level document to get
    419420        // assocfilepath - this could be cached too
    420         Element doc_meta_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
     421        Element doc_meta_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
    421422        dm_message.appendChild(doc_meta_request);
    422         Element doc_meta_param_list = this.doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
     423        Element doc_meta_param_list = doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
    423424        if (service_params != null)
    424425        {
    425             GSXML.addParametersToList(this.doc, doc_meta_param_list, service_params);
     426            GSXML.addParametersToList(doc, doc_meta_param_list, service_params);
    426427        }
    427428
    428429        doc_meta_request.appendChild(doc_meta_param_list);
    429         Element doc_param = this.doc.createElement(GSXML.PARAM_ELEM);
     430        Element doc_param = doc.createElement(GSXML.PARAM_ELEM);
    430431        doc_meta_param_list.appendChild(doc_param);
    431432        doc_param.setAttribute(GSXML.NAME_ATT, "metadata");
     
    433434
    434435        // create the doc node list for the metadata request
    435         Element doc_list = this.doc.createElement(GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER);
     436        Element doc_list = doc.createElement(GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER);
    436437        doc_meta_request.appendChild(doc_list);
    437438
    438         Element doc_node = this.doc.createElement(GSXML.DOC_NODE_ELEM);
     439        Element doc_node = doc.createElement(GSXML.DOC_NODE_ELEM);
    439440        // the node we want is the root document node
    440441        if (document_id != null)
     
    472473
    473474        // Build a request to obtain some document content
    474         Element dc_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
     475        Element dc_message = doc.createElement(GSXML.MESSAGE_ELEM);
    475476        to = GSPath.appendLink(collection, "DocumentContentRetrieve"); // Hard-wired?
    476         Element dc_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
     477        Element dc_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
    477478        dc_message.appendChild(dc_request);
    478479
    479480        // Create a parameter list to specify the request parameters - empty for now
    480         Element dc_param_list = this.doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
     481        Element dc_param_list = doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
    481482        if (service_params != null)
    482483        {
    483             GSXML.addParametersToList(this.doc, dc_param_list, service_params);
     484            GSXML.addParametersToList(doc, dc_param_list, service_params);
    484485        }
    485486
     
    518519                        content = highlightQueryTerms(request, (Element) content);
    519520                    }
    520                     doc_nodes.item(i).appendChild(this.doc.importNode(content, true));
     521                    doc_nodes.item(i).appendChild(doc.importNode(content, true));
    521522                }
    522523                //GSXML.mergeMetadataLists(doc_nodes.item(i), dm_response_docs.item(i));
     
    561562                    String enrich_service = (String) params.get(GSParams.SERVICE);
    562563                    // send a message to the service
    563                     Element enrich_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
    564                     Element enrich_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, enrich_service, userContext);
     564                    Element enrich_message = doc.createElement(GSXML.MESSAGE_ELEM);
     565                    Element enrich_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_PROCESS, enrich_service, userContext);
    565566                    enrich_message.appendChild(enrich_request);
    566567                    // check for parameters
     
    568569                    if (e_service_params != null)
    569570                    {
    570                         Element enrich_pl = this.doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
    571                         GSXML.addParametersToList(this.doc, enrich_pl, e_service_params);
     571                        Element enrich_pl = doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
     572                        GSXML.addParametersToList(doc, enrich_pl, e_service_params);
    572573                        enrich_request.appendChild(enrich_pl);
    573574                    }
    574                     Element e_doc_list = this.doc.createElement(GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER);
     575                    Element e_doc_list = doc.createElement(GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER);
    575576                    enrich_request.appendChild(e_doc_list);
    576                     e_doc_list.appendChild(this.doc.importNode(dc_response_doc, true));
     577                    e_doc_list.appendChild(doc.importNode(dc_response_doc, true));
    577578
    578579                    Node enrich_response = this.mr.process(enrich_message);
     
    595596
    596597                dummy_node.setAttribute(GSXML.NODE_ID_ATT, modified_doc_id);
    597                 dummy_node.appendChild(this.doc.importNode(dc_response_doc_content, true));
     598                dummy_node.appendChild(doc.importNode(dc_response_doc_content, true));
    598599                // hack for simple type
    599600                if (document_type.equals(GSXML.DOC_TYPE_SIMPLE))
     
    630631                    if (dn_id.equals(modified_doc_id))
    631632                    {
    632                         dn.appendChild(this.doc.importNode(dc_response_doc_content, true));
     633                        dn.appendChild(doc.importNode(dc_response_doc_content, true));
    633634                        break;
    634635                    }
     
    663664    protected boolean getBackgroundData(Element page_response, String collection, UserContext userContext)
    664665    {
    665 
     666        Document doc = page_response.getOwnerDocument();
     667       
    666668        // create a message to process - contains requests for the collection
    667669        // description, the format element, the enrich services on offer
    668670        // these could all be cached
    669         Element info_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
     671        Element info_message = doc.createElement(GSXML.MESSAGE_ELEM);
    670672        String path = GSPath.appendLink(collection, "DocumentContentRetrieve");
    671673        // the format request - ignore for now, where does this request go to??
    672         Element format_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_FORMAT, path, userContext);
     674        Element format_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_FORMAT, path, userContext);
    673675        info_message.appendChild(format_request);
    674676
     
    677679        if (provide_annotations)
    678680        {
    679             Element enrich_services_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, "", userContext);
     681            Element enrich_services_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_DESCRIBE, "", userContext);
    680682            enrich_services_request.setAttribute(GSXML.INFO_ATT, "serviceList");
    681683            info_message.appendChild(enrich_services_request);
     
    699701            // set the format type
    700702            format_elem.setAttribute(GSXML.TYPE_ATT, "display");
    701             page_response.appendChild(this.doc.importNode(format_elem, true));
     703            page_response.appendChild(doc.importNode(format_elem, true));
    702704        }
    703705
     
    707709
    708710            // a new message for the mr
    709             Element enrich_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
     711            Element enrich_message = doc.createElement(GSXML.MESSAGE_ELEM);
    710712            NodeList e_services = services_resp.getElementsByTagName(GSXML.SERVICE_ELEM);
    711713            boolean service_found = false;
     
    714716                if (((Element) e_services.item(j)).getAttribute(GSXML.TYPE_ATT).equals("enrich"))
    715717                {
    716                     Element s = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, ((Element) e_services.item(j)).getAttribute(GSXML.NAME_ATT), userContext);
     718                    Element s = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_DESCRIBE, ((Element) e_services.item(j)).getAttribute(GSXML.NAME_ATT), userContext);
    717719                    enrich_message.appendChild(s);
    718720                    service_found = true;
     
    724726
    725727                NodeList e_responses = enrich_response.getElementsByTagName(GSXML.RESPONSE_ELEM);
    726                 Element service_list = this.doc.createElement(GSXML.SERVICE_ELEM + GSXML.LIST_MODIFIER);
     728                Element service_list = doc.createElement(GSXML.SERVICE_ELEM + GSXML.LIST_MODIFIER);
    727729                for (int i = 0; i < e_responses.getLength(); i++)
    728730                {
    729731                    Element e_resp = (Element) e_responses.item(i);
    730                     Element e_service = (Element) this.doc.importNode(GSXML.getChildByTagName(e_resp, GSXML.SERVICE_ELEM), true);
     732                    Element e_service = (Element) doc.importNode(GSXML.getChildByTagName(e_resp, GSXML.SERVICE_ELEM), true);
    731733                    e_service.setAttribute(GSXML.NAME_ATT, e_resp.getAttribute(GSXML.FROM_ATT));
    732734                    service_list.appendChild(e_service);
     
    741743    protected String getDocumentType(Element basic_doc_list, String collection, UserContext userContext, Element page_response)
    742744    {
    743         Element ds_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
     745        Document doc = basic_doc_list.getOwnerDocument();
     746       
     747        Element ds_message = doc.createElement(GSXML.MESSAGE_ELEM);
    744748        String to = GSPath.appendLink(collection, "DocumentStructureRetrieve");// Hard-wired?
    745         Element ds_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
     749        Element ds_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
    746750        ds_message.appendChild(ds_request);
    747751
    748752        // Create a parameter list to specify the required structure information
    749         Element ds_param_list = this.doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
    750         Element ds_param = this.doc.createElement(GSXML.PARAM_ELEM);
     753        Element ds_param_list = doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
     754        Element ds_param = doc.createElement(GSXML.PARAM_ELEM);
    751755        ds_param_list.appendChild(ds_param);
    752756        ds_param.setAttribute(GSXML.NAME_ATT, "info");
     
    787791    protected Element highlightQueryTerms(Element request, Element dc_response_doc_content)
    788792    {
     793        Document doc = request.getOwnerDocument();
     794       
    789795        // do the query again to get term info
    790796        Element cgi_param_list = (Element) GSXML.getChildByTagName(request, GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
     
    806812        String to = GSPath.appendLink(collection, service_name);
    807813
    808         Element mr_query_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
    809         Element mr_query_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
     814        Element mr_query_message = doc.createElement(GSXML.MESSAGE_ELEM);
     815        Element mr_query_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
    810816        mr_query_message.appendChild(mr_query_request);
    811817
     
    813819        HashMap service_params = (HashMap) params.get("s1");
    814820
    815         Element query_param_list = this.doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
    816         GSXML.addParametersToList(this.doc, query_param_list, service_params);
     821        Element query_param_list = doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
     822        GSXML.addParametersToList(doc, query_param_list, service_params);
    817823        mr_query_request.appendChild(query_param_list);
    818824
     
    969975        }
    970976
    971         return highlightQueryTermsInternal(content, query_term_variants, phrase_query_term_variants_hierarchy);
     977        return highlightQueryTermsInternal(doc, content, query_term_variants, phrase_query_term_variants_hierarchy);
    972978    }
    973979
     
    975981     * Highlights query terms in a piece of text.
    976982     */
    977     private Element highlightQueryTermsInternal(String content, HashSet<String> query_term_variants, ArrayList<ArrayList<HashSet<String>>> phrase_query_term_variants_hierarchy)
     983    private Element highlightQueryTermsInternal(Document doc, String content, HashSet<String> query_term_variants, ArrayList<ArrayList<HashSet<String>>> phrase_query_term_variants_hierarchy)
    978984    {
    979985        // Convert the content string to an array of characters for speed
     
    11221128
    11231129        // Now add the annotation tags into the document at the correct points
    1124         Element content_element = this.doc.createElement(GSXML.NODE_CONTENT_ELEM);
     1130        Element content_element = doc.createElement(GSXML.NODE_CONTENT_ELEM);
    11251131
    11261132        int last_wrote = 0;
     
    11341140            {
    11351141                String preceding_text = new String(content_characters, last_wrote, (highlight_start - last_wrote));
    1136                 content_element.appendChild(this.doc.createTextNode(preceding_text));
     1142                content_element.appendChild(doc.createTextNode(preceding_text));
    11371143            }
    11381144
     
    11411147            {
    11421148                String highlight_text = new String(content_characters, highlight_start, (highlight_end - highlight_start));
    1143                 Element annotation_element = GSXML.createTextElement(this.doc, "annotation", highlight_text);
     1149                Element annotation_element = GSXML.createTextElement(doc, "annotation", highlight_text);
    11441150                annotation_element.setAttribute("type", "query_term");
    11451151                content_element.appendChild(annotation_element);
     
    11521158        {
    11531159            String remaining_text = new String(content_characters, last_wrote, (content_characters.length - last_wrote));
    1154             content_element.appendChild(this.doc.createTextNode(remaining_text));
     1160            content_element.appendChild(doc.createTextNode(remaining_text));
    11551161        }
    11561162
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/FormatAction.java

    r25635 r28382  
    4141   
    4242        Element message = this.converter.nodeToElement(message_node);
    43 
     43        Document doc = message.getOwnerDocument();
     44       
    4445        // assume only one request
    4546        Element request = (Element)GSXML.getChildByTagName(message, GSXML.REQUEST_ELEM);
     
    5152        HashMap<String, Serializable> params = GSXML.extractParams(cgi_param_list, false);
    5253
    53         Element result = this.doc.createElement(GSXML.MESSAGE_ELEM);
     54        Element result = doc.createElement(GSXML.MESSAGE_ELEM);
    5455   
    5556        String coll = (String)params.get(GSParams.COLLECTION); //SYSTEM_CLUSTER);
     
    6263        }
    6364
    64         Element mr_request_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
    65         Element mr_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_FORMAT_STRING, to, userContext);
     65        Element mr_request_message = doc.createElement(GSXML.MESSAGE_ELEM);
     66        Element mr_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_FORMAT_STRING, to, userContext);
    6667
    6768        mr_request.setAttribute("service", service);
     
    7475        String format_string = (String)params.get("data");
    7576   
    76         Element page_response = this.doc.createElement(GSXML.RESPONSE_ELEM);
     77        Element page_response = doc.createElement(GSXML.RESPONSE_ELEM);
    7778
    7879        Iterator<String> it = params.keySet().iterator();
     
    8081        if(subaction.equals("saveDocument"))
    8182        {
    82             Element format = this.doc.createElement(GSXML.FORMAT_STRING_ELEM);
     83            Element format = doc.createElement(GSXML.FORMAT_STRING_ELEM);
    8384            try{
    8485                DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
     
    8889                Node n1 = d.getFirstChild();
    8990
    90                 Element format_statement = (Element) this.doc.importNode(n1, true);
     91                Element format_statement = (Element) doc.importNode(n1, true);
    9192                format.appendChild(format_statement);
    9293                mr_request.appendChild(format);
     
    126127                    transformed = ((Document)transformed).getDocumentElement();
    127128
    128                 Element format = this.doc.createElement(GSXML.FORMAT_STRING_ELEM);
    129                 format.appendChild(this.doc.importNode(transformed,true));
     129                Element format = doc.createElement(GSXML.FORMAT_STRING_ELEM);
     130                format.appendChild(doc.importNode(transformed,true));
    130131                mr_request.appendChild(format);
    131132                logger.error("Transformed: "+transformed);
     
    145146        Node response_message = this.mr.process(mr_request_message);
    146147   
    147         result.appendChild(GSXML.duplicateWithNewName(this.doc, (Element)GSXML.getChildByTagName(response_message, GSXML.RESPONSE_ELEM), GSXML.RESPONSE_ELEM, true));
     148        result.appendChild(GSXML.duplicateWithNewName(doc, (Element)GSXML.getChildByTagName(response_message, GSXML.RESPONSE_ELEM), GSXML.RESPONSE_ELEM, true));
    148149        return result;
    149150   
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/GS2BrowseAction.java

    r26508 r28382  
    1212import org.greenstone.gsdl3.util.OID;
    1313import org.greenstone.gsdl3.util.UserContext;
     14import org.w3c.dom.Document;
    1415import org.w3c.dom.Element;
    1516import org.w3c.dom.Node;
     
    2930    public Node process(Node message_node)
    3031    {
    31 
    3232        Element message = this.converter.nodeToElement(message_node);
    33 
     33        Document doc = message.getOwnerDocument();
     34       
    3435        // get the request - assume only one
    3536        Element request = (Element) GSXML.getChildByTagName(message, GSXML.REQUEST_ELEM);
    3637
    3738        // the result
    38         Element result = this.doc.createElement(GSXML.MESSAGE_ELEM);
     39        Element result = doc.createElement(GSXML.MESSAGE_ELEM);
    3940        Element response = classifierBrowse(request);
    4041        result.appendChild(response);
     
    4445    protected Element classifierBrowse(Element request)
    4546    {
    46         Element page_response = this.doc.createElement(GSXML.RESPONSE_ELEM);
     47        Document doc = request.getOwnerDocument();
     48        Element page_response = doc.createElement(GSXML.RESPONSE_ELEM);
    4749
    4850        // extract the params from the cgi-request, and check that we have a coll specified
     
    7274        // this should be cached somehow later on.
    7375
    74         Element info_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
    75         Element info_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, to, userContext);
     76        Element info_message = doc.createElement(GSXML.MESSAGE_ELEM);
     77        Element info_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_DESCRIBE, to, userContext);
    7678        info_message.appendChild(info_request);
    7779
    7880        // also get the format stuff now if there is some
    79         Element format_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_FORMAT, to, userContext);
     81        Element format_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_FORMAT, to, userContext);
    8082        info_message.appendChild(format_request);
    8183        // process the requests
     
    8991
    9092        Element service_description = (Element) GSXML.getChildByTagName(service_response, GSXML.SERVICE_ELEM);
    91         page_response.appendChild(this.doc.importNode(service_description, true));
     93        page_response.appendChild(doc.importNode(service_description, true));
    9294
    9395        //append site metadata
     
    139141                }
    140142
    141                 Element new_format = GSXML.duplicateWithNewName(this.doc, this_format, GSXML.FORMAT_ELEM, false);
     143                Element new_format = GSXML.duplicateWithNewName(doc, this_format, GSXML.FORMAT_ELEM, false);
    142144                extractMetadataNames(new_format, doc_meta_names, class_meta_names);
    143145
     
    164166
    165167        // get the browse structure for the selected node
    166         Element classify_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
    167         Element classify_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
     168        Element classify_message = doc.createElement(GSXML.MESSAGE_ELEM);
     169        Element classify_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
    168170        classify_message.appendChild(classify_request);
    169171
    170172        //Create a parameter list to specify the required structure information
    171173        // for now, always get ancestors and children
    172         Element param_list = this.doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
     174        Element param_list = doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
    173175        classify_request.appendChild(param_list);
    174         Element param = this.doc.createElement(GSXML.PARAM_ELEM);
     176        Element param = doc.createElement(GSXML.PARAM_ELEM);
    175177        param_list.appendChild(param);
    176178        param.setAttribute(GSXML.NAME_ATT, "structure");
    177179        param.setAttribute(GSXML.VALUE_ATT, "ancestors");
    178         param = this.doc.createElement(GSXML.PARAM_ELEM);
     180        param = doc.createElement(GSXML.PARAM_ELEM);
    179181        param_list.appendChild(param);
    180182        param.setAttribute(GSXML.NAME_ATT, "structure");
     
    183185        if (get_descendants)
    184186        {
    185             param = this.doc.createElement(GSXML.PARAM_ELEM);
     187            param = doc.createElement(GSXML.PARAM_ELEM);
    186188            param_list.appendChild(param);
    187189            param.setAttribute(GSXML.NAME_ATT, "structure");
     
    191193
    192194        // put the classifier node into a classifier node list
    193         Element classifier_list = this.doc.createElement(GSXML.CLASS_NODE_ELEM + GSXML.LIST_MODIFIER);
    194         Element classifier = this.doc.createElement(GSXML.CLASS_NODE_ELEM);
     195        Element classifier_list = doc.createElement(GSXML.CLASS_NODE_ELEM + GSXML.LIST_MODIFIER);
     196        Element classifier = doc.createElement(GSXML.CLASS_NODE_ELEM);
    195197        classifier.setAttribute(GSXML.NODE_ID_ATT, classifier_node);
    196198        classifier_list.appendChild(classifier);
     
    233235                if (firstChildIsClassifierNode)
    234236                {
    235                     Element childStructure = getClassifierStructureFromID(classifier_node + ".1", request, collection, service_name);
     237                    Element childStructure = getClassifierStructureFromID(doc, classifier_node + ".1", request, collection, service_name);
    236238
    237239                    Element replacementElem = null;
     
    266268            else
    267269            {
    268                 Element childStructure = getClassifierStructureFromID(OID.getTop(classifier_node), request, collection, service_name);
     270                Element childStructure = getClassifierStructureFromID(doc, OID.getTop(classifier_node), request, collection, service_name);
    269271
    270272                String[] idParts = classifier_node.split("\\.");
     
    305307        Element page_classifier = null;
    306308        // add the single classifier node as the page classifier
    307         page_classifier = GSXML.duplicateWithNewName(this.doc, cl_structure, GSXML.CLASSIFIER_ELEM, true);
     309        page_classifier = GSXML.duplicateWithNewName(doc, cl_structure, GSXML.CLASSIFIER_ELEM, true);
    308310        page_response.appendChild(page_classifier);
    309311        page_classifier.setAttribute(GSXML.NAME_ATT, top_id);
     
    312314        // then for each document node
    313315
    314         Element metadata_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
     316        Element metadata_message = doc.createElement(GSXML.MESSAGE_ELEM);
    315317
    316318        boolean did_classifier = false;
     
    325327        {
    326328            did_classifier = true;
    327             Element cl_meta_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to + "MetadataRetrieve", userContext);
     329            Element cl_meta_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_PROCESS, to + "MetadataRetrieve", userContext);
    328330            metadata_message.appendChild(cl_meta_request);
    329331
    330             Element new_cl_nodes_list = this.doc.createElement(GSXML.CLASS_NODE_ELEM + GSXML.LIST_MODIFIER);
     332            Element new_cl_nodes_list = doc.createElement(GSXML.CLASS_NODE_ELEM + GSXML.LIST_MODIFIER);
    331333            cl_meta_request.appendChild(new_cl_nodes_list);
    332334
     
    334336            {
    335337
    336                 Element cl = this.doc.createElement(GSXML.CLASS_NODE_ELEM);
     338                Element cl = doc.createElement(GSXML.CLASS_NODE_ELEM);
    337339                cl.setAttribute(GSXML.NODE_ID_ATT, ((Element) cl_nodes.item(c)).getAttribute(GSXML.NODE_ID_ATT));
    338340                new_cl_nodes_list.appendChild(cl);
     
    342344            // should be based on info sent in from the recept, and the
    343345            // format stuff
    344             Element cl_param_list = createMetadataParamList(class_meta_names);
     346            Element cl_param_list = createMetadataParamList(doc,class_meta_names);
    345347            cl_meta_request.appendChild(cl_param_list);
    346348
     
    354356        {
    355357            did_documents = true;
    356             Element doc_meta_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, GSPath.appendLink(collection, "DocumentMetadataRetrieve"), userContext);
     358            Element doc_meta_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_PROCESS, GSPath.appendLink(collection, "DocumentMetadataRetrieve"), userContext);
    357359            metadata_message.appendChild(doc_meta_request);
    358360
    359             Element doc_list = this.doc.createElement(GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER);
     361            Element doc_list = doc.createElement(GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER);
    360362            doc_meta_request.appendChild(doc_list);
    361363
     
    363365            {
    364366
    365                 Element d = this.doc.createElement(GSXML.DOC_NODE_ELEM);
     367                Element d = doc.createElement(GSXML.DOC_NODE_ELEM);
    366368                d.setAttribute(GSXML.NODE_ID_ATT, ((Element) doc_nodes.item(c)).getAttribute(GSXML.NODE_ID_ATT));
    367369                doc_list.appendChild(d);
     
    369371
    370372            // create and add in the param list - add all for now
    371             Element doc_param_list = createMetadataParamList(doc_meta_names);
     373            Element doc_param_list = createMetadataParamList(doc,doc_meta_names);
    372374            doc_meta_request.appendChild(doc_param_list);
    373375
     
    431433    }
    432434
    433     private Element getClassifierStructureFromID(String id, Element request, String collection, String service_name)
     435    private Element getClassifierStructureFromID(Document doc, String id, Element request, String collection, String service_name)
    434436    {
    435437        UserContext userContext = new UserContext(request);
    436438        String to = GSPath.appendLink(collection, service_name);
    437439
    438         Element firstClassifierNodeChildrenMessage = this.doc.createElement(GSXML.MESSAGE_ELEM);
    439         Element firstClassifierNodeChildrenRequest = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
     440        Element firstClassifierNodeChildrenMessage = doc.createElement(GSXML.MESSAGE_ELEM);
     441        Element firstClassifierNodeChildrenRequest = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
    440442        firstClassifierNodeChildrenMessage.appendChild(firstClassifierNodeChildrenRequest);
    441443
    442         Element paramList = this.doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
     444        Element paramList = doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
    443445        firstClassifierNodeChildrenRequest.appendChild(paramList);
    444446
    445         Element ancestorParam = this.doc.createElement(GSXML.PARAM_ELEM);
     447        Element ancestorParam = doc.createElement(GSXML.PARAM_ELEM);
    446448        paramList.appendChild(ancestorParam);
    447449        ancestorParam.setAttribute(GSXML.NAME_ATT, "structure");
    448450        ancestorParam.setAttribute(GSXML.VALUE_ATT, "ancestors");
    449451
    450         Element childrenParam = this.doc.createElement(GSXML.PARAM_ELEM);
     452        Element childrenParam = doc.createElement(GSXML.PARAM_ELEM);
    451453        paramList.appendChild(childrenParam);
    452454        childrenParam.setAttribute(GSXML.NAME_ATT, "structure");
    453455        childrenParam.setAttribute(GSXML.VALUE_ATT, "children");
    454456
    455         Element classifierToGetList = this.doc.createElement(GSXML.CLASS_NODE_ELEM + GSXML.LIST_MODIFIER);
    456         Element classifierToGet = this.doc.createElement(GSXML.CLASS_NODE_ELEM);
     457        Element classifierToGetList = doc.createElement(GSXML.CLASS_NODE_ELEM + GSXML.LIST_MODIFIER);
     458        Element classifierToGet = doc.createElement(GSXML.CLASS_NODE_ELEM);
    457459        classifierToGet.setAttribute(GSXML.NODE_ID_ATT, id);
    458460        classifierToGetList.appendChild(classifierToGet);
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/GeneralAction.java

    r28202 r28382  
    3131    {
    3232        Element message = this.converter.nodeToElement(message_node);
    33 
     33        Document doc = message.getOwnerDocument();
     34       
    3435        // the result
    35         Element result = this.doc.createElement(GSXML.MESSAGE_ELEM);
    36         Element page_response = this.doc.createElement(GSXML.RESPONSE_ELEM);
     36        Element result = doc.createElement(GSXML.MESSAGE_ELEM);
     37        Element page_response = doc.createElement(GSXML.RESPONSE_ELEM);
    3738        result.appendChild(page_response);
    3839
     
    8788        {
    8889            //do the request
    89             Element mr_query_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
    90             Element mr_query_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
     90            Element mr_query_message = doc.createElement(GSXML.MESSAGE_ELEM);
     91            Element mr_query_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
    9192
    9293            if (request_type.equals("s"))
     
    102103            if (service_params != null)
    103104            {
    104                 param_list = this.doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
    105                 GSXML.addParametersToList(this.doc, param_list, service_params);
     105                param_list = doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
     106                GSXML.addParametersToList(doc, param_list, service_params);
    106107                mr_query_request.appendChild(param_list);
    107108            }
     
    110111            if (userInformation != null)
    111112            {
    112                 mr_query_request.appendChild(this.doc.importNode(userInformation, true));
     113                mr_query_request.appendChild(doc.importNode(userInformation, true));
    113114            }
    114115            mr_query_request.setAttribute("remoteAddress", request.getAttribute("remoteAddress"));
     
    134135
    135136        // request the service info for the selected service - should be cached
    136         Element mr_info_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
    137         Element mr_info_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, to, userContext);
     137        Element mr_info_message = doc.createElement(GSXML.MESSAGE_ELEM);
     138        Element mr_info_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_DESCRIBE, to, userContext);
    138139        mr_info_message.appendChild(mr_info_request);
    139140        Element mr_info_response = (Element) this.mr.process(mr_info_message);
     
    145146        if (desNode != null)
    146147        {
    147             page_response.appendChild((Element) this.doc.importNode(desNode, true));
     148            page_response.appendChild((Element) doc.importNode(desNode, true));
    148149        }
    149150
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/NoCollQueryAction.java

    r25635 r28382  
    3838
    3939        Element message = this.converter.nodeToElement(message_node);
    40 
     40        Document doc = message.getOwnerDocument();
     41       
    4142        // get the request - assume there is only one
    4243        Element request = (Element) GSXML.getChildByTagName(message, GSXML.REQUEST_ELEM);
    4344
    4445        // create the return message
    45         Element result = this.doc.createElement(GSXML.MESSAGE_ELEM);
     46        Element result = doc.createElement(GSXML.MESSAGE_ELEM);
    4647        // for now we only have one type of query - subaction not used
    4748        Element response = basicQuery(request);
    48         result.appendChild(this.doc.importNode(response, true));
     49        result.appendChild(doc.importNode(response, true));
    4950        return result;
    5051    }
     
    5253    /**
    5354     * a generic query handler this gets the service description, does the query
    54      * (just passes all teh params to the service, then gets the titles for any
     55     * (just passes all the params to the service, then gets the titles for any
    5556     * results
    5657     */
    5758    protected Element basicQuery(Element request)
    5859    {
    59 
    6060        // the result
    61         Element page_response = this.doc.createElement(GSXML.RESPONSE_ELEM);
     61        Document doc = request.getOwnerDocument();
     62       
     63        Element page_response = doc.createElement(GSXML.RESPONSE_ELEM);
    6264
    6365        // extract the params from the cgi-request, and check that we have a coll specified
     
    7274            // the only info we need to return is the collection list cos the xslt does teh rest
    7375
    74             Element coll_list = getCollectionList(userContext);
    75             page_response.appendChild(this.doc.importNode(coll_list, true));
     76            Element coll_list = getCollectionList(doc, userContext);
     77            page_response.appendChild(doc.importNode(coll_list, true));
    7678            return page_response;
    7779
     
    8991        {
    9092            logger.error("no collections were specified!");
    91             Element coll_list = getCollectionList(userContext);
    92             page_response.appendChild(this.doc.importNode(coll_list, true));
     93            Element coll_list = getCollectionList(doc,userContext);
     94            page_response.appendChild(doc.importNode(coll_list, true));
    9395            return page_response;
    9496        }
     
    100102            return page_response;
    101103        }
    102         Element query_param_list = this.doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
    103         GSXML.addParametersToList(this.doc, query_param_list, service_params);
     104        Element query_param_list = doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
     105        GSXML.addParametersToList(doc, query_param_list, service_params);
    104106
    105107        // we will do a query for each coll
    106108        String[] colls = query_coll_list.split(",");
    107109
    108         Element mr_query_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
     110        Element mr_query_message = doc.createElement(GSXML.MESSAGE_ELEM);
    109111
    110112        for (int i = 0; i < colls.length; i++)
    111113        {
    112114            String to = GSPath.appendLink(colls[i], service_name);
    113             Element mr_query_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
     115            Element mr_query_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
    114116            mr_query_message.appendChild(mr_query_request);
    115117            mr_query_request.appendChild(query_param_list.cloneNode(true));
     
    121123
    122124        // get the Title metadata for each node - need Node title and root title
    123         Element mr_meta_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
     125        Element mr_meta_message = doc.createElement(GSXML.MESSAGE_ELEM);
    124126        NodeList responses = mr_query_response.getElementsByTagName(GSXML.RESPONSE_ELEM);
    125127        for (int j = 0; j < responses.getLength(); j++)
     
    130132                String coll_name = extractCollName(((Element) responses.item(j)).getAttribute(GSXML.FROM_ATT));
    131133                String path = GSPath.appendLink(coll_name, "DocumentMetadataRetrieve");
    132                 Element mr_meta_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, path, userContext);
     134                Element mr_meta_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_PROCESS, path, userContext);
    133135                mr_meta_message.appendChild(mr_meta_request);
    134                 mr_meta_request.appendChild(this.doc.importNode(document_list, true));
     136                mr_meta_request.appendChild(doc.importNode(document_list, true));
    135137                // metadata params
    136                 Element param_list = this.doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
    137                 Element param = GSXML.createParameter(this.doc, "metadata", "Title");
     138                Element param_list = doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
     139                Element param = GSXML.createParameter(doc, "metadata", "Title");
    138140                param_list.appendChild(param);
    139                 param = GSXML.createParameter(this.doc, "metadata", "root_Title");
     141                param = GSXML.createParameter(doc, "metadata", "root_Title");
    140142                param_list.appendChild(param);
    141143                mr_meta_request.appendChild(param_list);
     
    148150
    149151        // the result
    150         Element result_doc_list = this.doc.createElement(GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER);
     152        Element result_doc_list = doc.createElement(GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER);
    151153        page_response.appendChild(result_doc_list);
    152154
     
    182184    }
    183185
    184     protected Element getCollectionList(UserContext userContext)
     186    protected Element getCollectionList(Document doc, UserContext userContext)
    185187    {
    186188
    187189        // first, get the message router info
    188         Element coll_list_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
    189         Element coll_list_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, "", userContext);
     190        Element coll_list_message = doc.createElement(GSXML.MESSAGE_ELEM);
     191        Element coll_list_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_DESCRIBE, "", userContext);
    190192        coll_list_message.appendChild(coll_list_request);
    191193        Element coll_list_response = (Element) this.mr.process(coll_list_message);
     
    199201        NodeList colls = coll_list_response.getElementsByTagName(GSXML.COLLECTION_ELEM);
    200202
    201         Element coll_param_list = this.doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
    202         Element param = GSXML.createParameter(this.doc, GSXML.SUBSET_PARAM, GSXML.DISPLAY_TEXT_ELEM + GSXML.LIST_MODIFIER);
     203        Element coll_param_list = doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
     204        Element param = GSXML.createParameter(doc, GSXML.SUBSET_PARAM, GSXML.DISPLAY_TEXT_ELEM + GSXML.LIST_MODIFIER);
    203205        coll_param_list.appendChild(param);
    204206        // we will send all the requests in a single message
    205         Element metadata_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
     207        Element metadata_message = doc.createElement(GSXML.MESSAGE_ELEM);
    206208        for (int i = 0; i < colls.getLength(); i++)
    207209        {
     
    209211            String name = c.getAttribute(GSXML.NAME_ATT);
    210212
    211             Element metadata_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, name, userContext);
     213            Element metadata_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_DESCRIBE, name, userContext);
    212214            metadata_request.appendChild(coll_param_list.cloneNode(true));
    213215            metadata_message.appendChild(metadata_request);
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/PageAction.java

    r27617 r28382  
    1010import org.greenstone.gsdl3.util.UserContext;
    1111import org.greenstone.util.GlobalProperties;
     12import org.w3c.dom.Document;
    1213import org.w3c.dom.Element;
    1314import org.w3c.dom.Node;
     
    2627    {
    2728        Element message = this.converter.nodeToElement(message_node);
     29        Document doc = message.getOwnerDocument();
     30       
    2831        Element request = (Element) GSXML.getChildByTagName(message, GSXML.REQUEST_ELEM);
    2932        Element paramList = (Element) GSXML.getChildByTagName(request, GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
     
    4447            page_name = HOME_PAGE;
    4548        }
    46         Element result = this.doc.createElement(GSXML.MESSAGE_ELEM);
     49        Element result = doc.createElement(GSXML.MESSAGE_ELEM);
    4750        Element response;
    4851        if (page_name.equals(HOME_PAGE))
     
    6669        }
    6770
    68         Element formatMessage = this.doc.createElement(GSXML.MESSAGE_ELEM);
    69         Element formatRequest = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_FORMAT, collection, new UserContext(request));
     71        Element formatMessage = doc.createElement(GSXML.MESSAGE_ELEM);
     72        Element formatRequest = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_FORMAT, collection, new UserContext(request));
    7073        formatMessage.appendChild(formatRequest);
    7174        Element formatResponseMessage = (Element) this.mr.process(formatMessage);
     
    7881        }
    7982
    80         result.appendChild(this.doc.importNode(response, true));
     83        result.appendChild(doc.importNode(response, true));
    8184        logger.debug("page action result: " + this.converter.getPrettyString(result));
    8285
     
    8689    protected Element homePage(Element request)
    8790    {
     91        Document doc = request.getOwnerDocument();
     92       
    8893        UserContext userContext = new UserContext(request);
    8994        // first, get the message router info
    90         Element info_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
    91         Element coll_list_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, "", userContext);
     95        Element info_message = doc.createElement(GSXML.MESSAGE_ELEM);
     96        Element coll_list_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_DESCRIBE, "", userContext);
    9297        info_message.appendChild(coll_list_request);
    9398        Element info_response_message = (Element) this.mr.process(info_message);
     
    113118            if (colls.getLength() > 0)
    114119            {
    115                 sendMultipleRequests(colls, null, GSXML.REQUEST_TYPE_DESCRIBE, userContext);
     120                sendMultipleRequests(doc, colls, null, GSXML.REQUEST_TYPE_DESCRIBE, userContext);
    116121            }
    117122        }
     
    124129            if (services.getLength() > 0)
    125130            {
    126                 sendMultipleRequests(services, null, GSXML.REQUEST_TYPE_DESCRIBE, userContext);
     131                sendMultipleRequests(doc, services, null, GSXML.REQUEST_TYPE_DESCRIBE, userContext);
    127132            }
    128133        }
     
    135140            if (clusters.getLength() > 0)
    136141            {
    137                 sendMultipleRequests(clusters, null, GSXML.REQUEST_TYPE_DESCRIBE, userContext);
     142                sendMultipleRequests(doc, clusters, null, GSXML.REQUEST_TYPE_DESCRIBE, userContext);
    138143
    139144            }
     
    149154    protected Element aboutPage(Element request)
    150155    {
     156        Document doc = request.getOwnerDocument();
     157       
    151158        UserContext userContext = new UserContext(request);
    152159        // extract the params from the cgi-request,
     
    159166            logger.error("about page requested with no collection or cluster specified!");
    160167            // return an empty response
    161             Element response = this.doc.createElement(GSXML.RESPONSE_ELEM);
     168            Element response = doc.createElement(GSXML.RESPONSE_ELEM);
    162169            addSiteMetadata(response, userContext);
    163170            addInterfaceOptions(response);
     
    166173
    167174        // get the collection or cluster description
    168         Element coll_about_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
    169 
    170         Element coll_about_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, coll_name, userContext);
     175        Element coll_about_message = doc.createElement(GSXML.MESSAGE_ELEM);
     176
     177        Element coll_about_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_DESCRIBE, coll_name, userContext);
    171178        coll_about_message.appendChild(coll_about_request);
    172179        Element coll_about_response = (Element) this.mr.process(coll_about_message);
     
    213220        if (services.getLength() > 0)
    214221        {
    215             sendMultipleRequests(services, coll_name, GSXML.REQUEST_TYPE_DESCRIBE, userContext);
     222            sendMultipleRequests(doc, services, coll_name, GSXML.REQUEST_TYPE_DESCRIBE, userContext);
    216223        }
    217224
     
    231238    protected Element unknownPage(Element request)
    232239    {
     240        Document doc = request.getOwnerDocument();
     241       
    233242        UserContext userContext = new UserContext(request);
    234243        String page_name = request.getAttribute(GSXML.SUBACTION_ATT);
     
    242251        {
    243252            // just return an empty response
    244             Element response = this.doc.createElement(GSXML.RESPONSE_ELEM);
     253            Element response = doc.createElement(GSXML.RESPONSE_ELEM);
    245254            addSiteMetadata(response, userContext);
    246255            addInterfaceOptions(response);
     
    252261        // if there is a service specified should we get the service description instead??
    253262        // get the collection or cluster description
    254         Element coll_about_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
    255 
    256         Element coll_about_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, coll_name, userContext);
     263        Element coll_about_message = doc.createElement(GSXML.MESSAGE_ELEM);
     264
     265        Element coll_about_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_DESCRIBE, coll_name, userContext);
    257266        coll_about_message.appendChild(coll_about_request);
    258267
     
    269278    }
    270279
    271     protected boolean sendMultipleRequests(NodeList items, String path_prefix, String request_type, UserContext userContext)
     280    protected boolean sendMultipleRequests(Document doc, NodeList items, String path_prefix, String request_type, UserContext userContext)
    272281    {
    273282        // we will send all the requests in a single message
    274         Element message = this.doc.createElement(GSXML.MESSAGE_ELEM);
     283        Element message = doc.createElement(GSXML.MESSAGE_ELEM);
    275284        for (int i = 0; i < items.getLength(); i++)
    276285        {
     
    281290                path = GSPath.appendLink(path_prefix, path);
    282291            }
    283             Element request = GSXML.createBasicRequest(this.doc, request_type, path, userContext);
     292            Element request = GSXML.createBasicRequest(doc, request_type, path, userContext);
    284293            message.appendChild(request);
    285294        }
     
    317326    protected Element gli4gs3Page(Element request)
    318327    {
     328        Document doc = request.getOwnerDocument();
     329       
    319330        String lang = request.getAttribute(GSXML.LANG_ATT);
    320331        String uid = request.getAttribute(GSXML.USER_ID_ATT);
    321332
    322         Element page_response = this.doc.createElement(GSXML.RESPONSE_ELEM);
    323 
    324         Element applet_elem = this.doc.createElement("Applet");
     333        Element page_response = doc.createElement(GSXML.RESPONSE_ELEM);
     334
     335        Element applet_elem = doc.createElement("Applet");
    325336        page_response.appendChild(applet_elem);
    326337        applet_elem.setAttribute("ARCHIVE", "SignedGatherer.jar");
     
    329340        applet_elem.setAttribute("HEIGHT", "50");
    330341        applet_elem.setAttribute("WIDTH", "380");
    331         Element gwcgi_param_elem = this.doc.createElement("PARAM");
     342        Element gwcgi_param_elem = doc.createElement("PARAM");
    332343        gwcgi_param_elem.setAttribute("name", "gwcgi");
    333344        String library_name = GlobalProperties.getGSDL3WebAddress();
     
    335346        applet_elem.appendChild(gwcgi_param_elem);
    336347
    337         Element gsdl3_param_elem = this.doc.createElement("PARAM");
     348        Element gsdl3_param_elem = doc.createElement("PARAM");
    338349        gsdl3_param_elem.setAttribute("name", "gsdl3");
    339350        gsdl3_param_elem.setAttribute("value", "true");
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/ProcessAction.java

    r25635 r28382  
    2121    public Node process(Node message_node)
    2222    {
    23 
    2423        Element message = this.converter.nodeToElement(message_node);
    25 
     24        Document doc = message.getOwnerDocument();
     25       
    2626        // the result
    27         Element result = this.doc.createElement(GSXML.MESSAGE_ELEM);
    28         Element page_response = this.doc.createElement(GSXML.RESPONSE_ELEM);
     27        Element result = doc.createElement(GSXML.MESSAGE_ELEM);
     28        Element page_response = doc.createElement(GSXML.RESPONSE_ELEM);
    2929        result.appendChild(page_response);
    3030
     
    7070            // if rt=s or rt=r, do the request
    7171
    72             Element mr_query_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
     72            Element mr_query_message = doc.createElement(GSXML.MESSAGE_ELEM);
    7373            String request_type_att;
    7474            Element param_list = null;
     
    7676            { // status
    7777                request_type_att = GSXML.REQUEST_TYPE_STATUS;
    78                 param_list = this.doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
    79                 Element param = this.doc.createElement(GSXML.PARAM_ELEM);
     78                param_list = doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
     79                Element param = doc.createElement(GSXML.PARAM_ELEM);
    8080                param.setAttribute(GSXML.NAME_ATT, GSParams.PROCESS_ID);
    8181                param.setAttribute(GSXML.VALUE_ATT, (String) params.get(GSParams.PROCESS_ID));
     
    8989                if (service_params != null)
    9090                {
    91                     param_list = this.doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
    92                     GSXML.addParametersToList(this.doc, param_list, service_params);
     91                    param_list = doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
     92                    GSXML.addParametersToList(doc, param_list, service_params);
    9393                }
    9494
    9595            }
    96             Element mr_query_request = GSXML.createBasicRequest(this.doc, request_type_att, to, userContext);
     96            Element mr_query_request = GSXML.createBasicRequest(doc, request_type_att, to, userContext);
    9797            if (param_list != null)
    9898            {
     
    112112            // else append the contents of the response to the page - just the status elem for now
    113113            Element status = (Element) GSXML.getChildByTagName(result_response, GSXML.STATUS_ELEM);
    114             page_response.appendChild(this.doc.importNode(status, true));
     114            page_response.appendChild(doc.importNode(status, true));
    115115        }
    116116
     
    118118
    119119        // request the service info for the selected service - should be cached
    120         Element mr_info_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
    121         Element mr_info_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, to, userContext);
     120        Element mr_info_message = doc.createElement(GSXML.MESSAGE_ELEM);
     121        Element mr_info_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_DESCRIBE, to, userContext);
    122122        mr_info_message.appendChild(mr_info_request);
    123123        Element mr_info_response = (Element) this.mr.process(mr_info_message);
     
    125125        String path = GSXML.RESPONSE_ELEM;
    126126        path = GSPath.appendLink(path, GSXML.SERVICE_ELEM);
    127         Element description = (Element) this.doc.importNode(GSXML.getNodeByPath(mr_info_response, path), true);
     127        Element description = (Element) doc.importNode(GSXML.getNodeByPath(mr_info_response, path), true);
    128128
    129129        page_response.appendChild(description);
     
    134134    protected Element getServiceParamList(Element cgi_param_list)
    135135    {
    136 
    137         Element new_param_list = this.doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
     136        Document doc = cgi_param_list.getOwnerDocument();
     137       
     138        Element new_param_list = doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
    138139        Element param;
    139140        NodeList cgi_params = cgi_param_list.getChildNodes();
     
    147148            }
    148149            // else add it in to the list
    149             new_param_list.appendChild(this.doc.importNode(p, true));
     150            new_param_list.appendChild(doc.importNode(p, true));
    150151        }
    151152        return new_param_list;
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/QueryAction.java

    r27145 r28382  
    1111import org.greenstone.gsdl3.util.GSXSLT;
    1212import org.greenstone.gsdl3.util.UserContext;
     13import org.w3c.dom.Document;
    1314import org.w3c.dom.Element;
    1415import org.w3c.dom.Node;
     
    2627    public Node process(Node message_node)
    2728    {
    28 
    2929        Element message = this.converter.nodeToElement(message_node);
    30 
     30        Document doc = message.getOwnerDocument();
     31       
    3132        // get the request - assume there is only one
    3233        Element request = (Element) GSXML.getChildByTagName(message, GSXML.REQUEST_ELEM);
    3334
    3435        // create the return message
    35         Element result = this.doc.createElement(GSXML.MESSAGE_ELEM);
     36        Element result = doc.createElement(GSXML.MESSAGE_ELEM);
    3637        Element response = basicQuery(request);
    37         result.appendChild(this.doc.importNode(response, true));
     38        result.appendChild(doc.importNode(response, true));
    3839        return result;
    3940    }
     
    4748    {
    4849        // the result
    49         Element page_response = this.doc.createElement(GSXML.RESPONSE_ELEM);
     50        Document doc = request.getOwnerDocument();
     51        Element page_response = doc.createElement(GSXML.RESPONSE_ELEM);
    5052
    5153        // extract the params from the cgi-request, and check that we have a coll specified
     
    7577        format_elem.setAttribute(GSXML.TYPE_ATT, "search");
    7678        // for now just add to the response
    77         page_response.appendChild(this.doc.importNode(format_elem, true));
     79        page_response.appendChild(doc.importNode(format_elem, true));
    7880
    7981        if (request_type.indexOf("d") != -1)
    8082        {
    8183            // we have been asked for the service description
    82             Element mr_info_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
    83             Element mr_info_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, to, userContext);
     84            Element mr_info_message = doc.createElement(GSXML.MESSAGE_ELEM);
     85            Element mr_info_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_DESCRIBE, to, userContext);
    8486            mr_info_message.appendChild(mr_info_request);
    8587
     
    9092            Element service_response = (Element) GSXML.getChildByTagName(mr_info_response, GSXML.RESPONSE_ELEM);
    9193
    92             Element service_description = (Element) this.doc.importNode(GSXML.getChildByTagName(service_response, GSXML.SERVICE_ELEM), true);
     94            Element service_description = (Element) doc.importNode(GSXML.getChildByTagName(service_response, GSXML.SERVICE_ELEM), true);
    9395            page_response.appendChild(service_description);
    9496        }
     
    114116
    115117        // create the query request
    116         Element mr_query_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
    117         Element mr_query_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
     118        Element mr_query_message = doc.createElement(GSXML.MESSAGE_ELEM);
     119        Element mr_query_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
    118120        mr_query_message.appendChild(mr_query_request);
    119121
    120         Element query_param_list = this.doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
    121         GSXML.addParametersToList(this.doc, query_param_list, service_params);
     122        Element query_param_list = doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
     123        GSXML.addParametersToList(doc, query_param_list, service_params);
    122124        mr_query_request.appendChild(query_param_list);
    123125
     
    144146        else
    145147        { // add it into the page response
    146             page_response.appendChild(this.doc.importNode(query_result_metadata_list, true));
     148            page_response.appendChild(doc.importNode(query_result_metadata_list, true));
    147149        }
    148150
     
    154156        else
    155157        { // add it into the page response
    156             page_response.appendChild(this.doc.importNode(query_term_info_list, true));
     158            page_response.appendChild(doc.importNode(query_term_info_list, true));
    157159        }
    158160
     
    164166        else
    165167        { // add it into the page response
    166             page_response.appendChild(this.doc.importNode(facet_list, true));
     168            page_response.appendChild(doc.importNode(facet_list, true));
    167169        }
    168170
     
    173175        {
    174176            // add in a dummy doc node list - used by the display. need to think about this
    175             page_response.appendChild(this.doc.createElement(GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER));
     177            page_response.appendChild(doc.createElement(GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER));
    176178            //append site metadata
    177179            addSiteMetadata(page_response, userContext);
     
    186188            logger.error("have already found metadata!");
    187189            // append the doc list to the result
    188             page_response.appendChild(this.doc.importNode(document_list, true));
     190            page_response.appendChild(doc.importNode(document_list, true));
    189191            //append site metadata
    190192            addSiteMetadata(page_response, userContext);
     
    203205
    204206        // paging of the results is done here - we filter the list to remove unwanted entries before retrieving metadata
    205         Element filtered_doc_list = filterDocList(params, service_params, document_list);
     207        Element filtered_doc_list = filterDocList(doc, params, service_params, document_list);
    206208
    207209        // do the metadata request on the filtered list
    208         Element mr_metadata_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
     210        Element mr_metadata_message = doc.createElement(GSXML.MESSAGE_ELEM);
    209211        to = "DocumentMetadataRetrieve";
    210212        if (collection != null)
     
    212214            to = GSPath.prependLink(to, collection);
    213215        }
    214         Element mr_metadata_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
     216        Element mr_metadata_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
    215217        mr_metadata_message.appendChild(mr_metadata_request);
    216218
     
    228230        }
    229231
    230         Element dm_param_list = createMetadataParamList(metadata_names);
     232        Element dm_param_list = createMetadataParamList(doc,metadata_names);
    231233
    232234        mr_metadata_request.appendChild(dm_param_list);
     
    246248        if (query_result_document_list != null)
    247249        {
    248             page_response.appendChild(this.doc.importNode(query_result_document_list, true));
     250            page_response.appendChild(doc.importNode(query_result_document_list, true));
    249251        }
    250252
     
    257259
    258260    /** this filters out some of the doc results for result paging */
    259     protected Element filterDocList(HashMap<String, Serializable> params, HashMap service_params, Element orig_doc_list)
     261    protected Element filterDocList(Document doc, HashMap<String, Serializable> params, HashMap service_params, Element orig_doc_list)
    260262    {
    261263
     
    265267        {
    266268            // the service is doing the paging, so we want to display all of the returned docs(???)
    267             //    return (Element)this.doc.importNode(orig_doc_list, true);
     269            //    return (Element)doc.importNode(orig_doc_list, true);
    268270            // try hitsPerPage in the globle param
    269271            hits_pp = (String) params.get("hitsPerPage");
     
    285287        if (hits == -1)
    286288        { // all
    287             return (Element) this.doc.importNode(orig_doc_list, true);
     289            return (Element) doc.importNode(orig_doc_list, true);
    288290        }
    289291        NodeList result_docs = orig_doc_list.getElementsByTagName(GSXML.DOC_NODE_ELEM);
     
    293295        {
    294296            // too few docs to do paging
    295             return (Element) this.doc.importNode(orig_doc_list, true);
     297            return (Element) doc.importNode(orig_doc_list, true);
    296298        }
    297299
    298300        // now we need our own doc list
    299         Element result_list = this.doc.createElement(GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER);
     301        Element result_list = doc.createElement(GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER);
    300302
    301303        String start_p = (String) service_params.get("startPage");
     
    335337        for (int i = start_from; i <= end_at; i++)
    336338        {
    337             result_list.appendChild(this.doc.importNode(result_docs.item(i), true));
     339            result_list.appendChild(doc.importNode(result_docs.item(i), true));
    338340        }
    339341
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/RSSAction.java

    r27087 r28382  
    44
    55// XML classes
     6import org.w3c.dom.Document;
    67import org.w3c.dom.Node;
    78import org.w3c.dom.Element;
     
    2627    public Node process(Node message_node)
    2728    {
    28 
    2929        Element message = this.converter.nodeToElement(message_node);
    30 
     30        Document doc = message.getOwnerDocument();
     31       
    3132        // assume only one request
    3233        Element request = (Element) GSXML.getChildByTagName(message, GSXML.REQUEST_ELEM);
     
    4546        // this should be cached somehow later on.
    4647   
    47         Element mr_request_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
    48         Element rss_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
     48        Element mr_request_message = doc.createElement(GSXML.MESSAGE_ELEM);
     49        Element rss_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
    4950        mr_request_message.appendChild(rss_request);
    5051
     
    5859        addInterfaceOptions(rss_response);
    5960
    60         Element result = this.doc.createElement(GSXML.MESSAGE_ELEM);
    61         result.appendChild(this.doc.importNode(rss_response, true));
     61        Element result = doc.createElement(GSXML.MESSAGE_ELEM);
     62        result.appendChild(doc.importNode(rss_response, true));
    6263        return result;
    6364
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/SystemAction.java

    r25636 r28382  
    44
    55// XML classes
     6import org.w3c.dom.Document;
    67import org.w3c.dom.Node;
    78import org.w3c.dom.Element;
     
    2829    public Node process(Node message_node)
    2930    {
    30 
    3131        Element message = this.converter.nodeToElement(message_node);
    32 
     32        Document doc = message.getOwnerDocument();
     33       
    3334        // assume only one request
    3435        Element request = (Element) GSXML.getChildByTagName(message, GSXML.REQUEST_ELEM);
     
    4041        HashMap<String, Serializable> params = GSXML.extractParams(cgi_param_list, false);
    4142
    42         Element result = this.doc.createElement(GSXML.MESSAGE_ELEM);
     43        Element result = doc.createElement(GSXML.MESSAGE_ELEM);
    4344
    4445        String coll = (String) params.get(GSParams.SYSTEM_CLUSTER);
     
    5051        }
    5152
    52         Element mr_request_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
    53         Element mr_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_SYSTEM, to, userContext);
     53        Element mr_request_message = doc.createElement(GSXML.MESSAGE_ELEM);
     54        Element mr_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_SYSTEM, to, userContext);
    5455        mr_request_message.appendChild(mr_request);
    5556
    56         Element system = this.doc.createElement(GSXML.SYSTEM_ELEM);
     57        Element system = doc.createElement(GSXML.SYSTEM_ELEM);
    5758        mr_request.appendChild(system);
    5859
     
    109110                // for now just have an error
    110111                logger.error("bad subaction type");
    111                 Element page_response = this.doc.createElement(GSXML.RESPONSE_ELEM);
     112                Element page_response = doc.createElement(GSXML.RESPONSE_ELEM);
    112113                result.appendChild(page_response);
    113114
     
    118119        Node response_message = this.mr.process(mr_request_message);
    119120
    120         Element response = GSXML.duplicateWithNewName(this.doc, (Element) GSXML.getChildByTagName(response_message, GSXML.RESPONSE_ELEM), GSXML.RESPONSE_ELEM, true);
     121        Element response = GSXML.duplicateWithNewName(doc, (Element) GSXML.getChildByTagName(response_message, GSXML.RESPONSE_ELEM), GSXML.RESPONSE_ELEM, true);
    121122        addSiteMetadata(response, userContext);
    122123        addInterfaceOptions(response);
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/XMLDocumentAction.java

    r25635 r28382  
    2828    public Node process(Node message_node)
    2929    {
    30 
    3130        Element message = this.converter.nodeToElement(message_node);
    32 
     31        Document doc = message.getOwnerDocument();
     32       
    3333        // get the request - assume there is only one
    3434        Element request = (Element) GSXML.getChildByTagName(message, GSXML.REQUEST_ELEM);
    3535
    3636        // create the return message
    37         Element result = this.doc.createElement(GSXML.MESSAGE_ELEM);
    38         Element page_response = this.doc.createElement(GSXML.RESPONSE_ELEM);
     37        Element result = doc.createElement(GSXML.MESSAGE_ELEM);
     38        Element page_response = doc.createElement(GSXML.RESPONSE_ELEM);
    3939        result.appendChild(page_response);
    4040
     
    7575
    7676        // make the request to the collection
    77         Element mr_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
     77        Element mr_message = doc.createElement(GSXML.MESSAGE_ELEM);
    7878
    79         Element ret_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
     79        Element ret_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
    8080        mr_message.appendChild(ret_request);
    8181
    82         Element doc_list = this.doc.createElement(GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER);
     82        Element doc_list = doc.createElement(GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER);
    8383        ret_request.appendChild(doc_list);
    84         Element doc = this.doc.createElement(GSXML.DOC_NODE_ELEM);
    85         doc.setAttribute(GSXML.NODE_ID_ATT, doc_name);
    86         doc_list.appendChild(doc);
     84        Element docelem = doc.createElement(GSXML.DOC_NODE_ELEM);
     85        docelem.setAttribute(GSXML.NODE_ID_ATT, doc_name);
     86        doc_list.appendChild(docelem);
    8787
    8888        // also add in a request for the Title metadata
    8989        to = GSPath.appendLink(collection, "DocumentMetadataRetrieve");
    90         Element meta_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
     90        Element meta_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
    9191        // copy the doc list
    9292        meta_request.appendChild(doc_list.cloneNode(true));
    9393        // add in a metadata param
    94         Element param_list = this.doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
     94        Element param_list = doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
    9595        meta_request.appendChild(param_list);
    96         Element param = GSXML.createParameter(this.doc, "metadata", "root_Title");
     96        Element param = GSXML.createParameter(doc, "metadata", "root_Title");
    9797        param_list.appendChild(param);
    9898
     
    103103        String[] links = { GSXML.RESPONSE_ELEM, GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER, GSXML.DOC_NODE_ELEM };
    104104        String path = GSPath.createPath(links);
    105         Element doc_node = (Element) this.doc.importNode(GSXML.getNodeByPath(ret_response, path), true);
     105        Element doc_node = (Element) doc.importNode(GSXML.getNodeByPath(ret_response, path), true);
    106106        page_response.appendChild(doc_node);
    107107
     
    114114        if (meta_list != null)
    115115        {
    116             doc_node.appendChild(this.doc.importNode(meta_list, true));
     116            doc_node.appendChild(doc.importNode(meta_list, true));
    117117        }
    118118        return result;
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/XMLConverter.java

    r26168 r28382  
    266266
    267267    /** creates a new empty DOM Document */
    268     public static Document newDOM()
     268    public Document newDOM()
    269269    {
    270270        Document doc = new DocumentImpl();
Note: See TracChangeset for help on using the changeset viewer.