Ignore:
Timestamp:
2018-02-12T22:22:51+13:00 (6 years ago)
Author:
Georgiy Litvinov
Message:

Remove all sections from requests except needed by inline template.

File:
1 edited

Legend:

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

    r32111 r32128  
    527527            // Add the documentNode to the list
    528528            Element dm_doc_node = doc.createElement(GSXML.DOC_NODE_ELEM);
    529             dm_doc_list.appendChild(dm_doc_node);
     529            if (needSectionContent(params)) {
     530                if (doc_node_id.equals(document_id)) {
     531                    dm_doc_list.appendChild(dm_doc_node);
     532                }
     533            } else {
     534                dm_doc_list.appendChild(dm_doc_node);
     535            }
     536            //dm_doc_list.appendChild(dm_doc_node);
    530537            dm_doc_node.setAttribute(GSXML.NODE_ID_ATT, doc_node_id);
    531538            dm_doc_node.setAttribute(GSXML.NODE_TYPE_ATT, doc_node.getAttribute(GSXML.NODE_TYPE_ATT));
     
    535542
    536543        }
    537 
    538544        // we also want a metadata request to the top level document to get
    539545        // assocfilepath - this could be cached too
     
    584590        for (int i = 0; i < doc_nodes.getLength(); i++)
    585591        {
    586             GSXML.mergeMetadataLists(doc_nodes.item(i), dm_response_docs.item(i));
     592            String node_idd = ((Element)doc_nodes.item(i)).getAttribute(GSXML.NODE_ID_ATT);
     593            Node dcNode = GSXML.getNamedElement(dm_response_doc_list, "documentNode", GSXML.NODE_ID_ATT, node_idd);
     594            GSXML.mergeMetadataLists(doc_nodes.item(i), dcNode);
    587595        }
    588596        // get the top level doc metadata out
     
    623631        }
    624632        Element dc_response_message = (Element) this.mr.process(dc_message);
     633
    625634        if (processErrorElements(dc_response_message, page_response))
    626635        {
    627636            return result;
     637           
    628638        }
    629639        Element dc_response_doc_list = (Element) GSXML.getNodeByPath(dc_response_message, path);
     
    635645            for (int i = 0; i < doc_nodes.getLength(); i++)
    636646            {
    637                 Node content = GSXML.getChildByTagName((Element) dc_response_docs.item(i), GSXML.NODE_CONTENT_ELEM);
     647                String node_id = ((Element)doc_nodes.item(i)).getAttribute(GSXML.NODE_ID_ATT);
     648                //Node content = GSXML.getChildByTagName((Element) dc_response_docs.item(i), GSXML.NODE_CONTENT_ELEM);
     649                Node docNode = GSXML.getNamedElement(dc_response_doc_list, "documentNode", GSXML.NODE_ID_ATT, node_id);
     650                Node content = GSXML.getChildByTagName(docNode, GSXML.NODE_CONTENT_ELEM);
    638651                if (content != null)
    639652                {
    640653                    if (highlight_query_terms)
    641654                    {
    642                       String node_id = ((Element)doc_nodes.item(i)).getAttribute(GSXML.NODE_ID_ATT);
     655                     
    643656                      content = highlightQueryTerms(request, node_id, (Element) content);
    644657                    }
     
    799812        return true;
    800813    }
    801 
     814   
     815    private boolean needSectionContent(HashMap<String, Serializable> params) {
     816        String document_id = (String) params.get(GSParams.DOCUMENT);
     817        String ilt = (String) params.get(GSParams.INLINE_TEMPLATE);
     818        String iltPrefix = "<xsl:template match=\"/\"><text><xsl:for-each select=\"/page/pageResponse/document//documentNode[@nodeID =";
     819        if (ilt != null && ilt.startsWith(iltPrefix) && document_id != null) {
     820            return true;
     821        }
     822   
     823        return false;
     824    }
    802825    /**
    803826     * this method gets the collection description, the format info, the list of
Note: See TracChangeset for help on using the changeset viewer.