Changeset 32075


Ignore:
Timestamp:
11/16/17 15:11:39 (3 years ago)
Author:
kjdon
Message:

don;t bother finding out document type from server if it has already been specified in parameters. simple documents don't have <document><documnetNode>, they just have <document>.

File:
1 edited

Legend:

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

    r32071 r32075  
    194194
    195195          // work out doctype
     196          // NOTE: this will be coming from collection database in index
     197          // the archive file doesn't store this. So we have to assume
     198          // that the doc type will not be changing with any
     199          // modifications happening to archives.
     200         
     201          // if doc type is null, then we need to work it out.
    196202          // create a basic doc list containing the current node
    197           Element basic_doc_list = doc.createElement(GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER);
    198           Element current_doc = doc.createElement(GSXML.DOC_NODE_ELEM);
    199           basic_doc_list.appendChild(current_doc);
    200           current_doc.setAttribute(GSXML.NODE_ID_ATT, document_id);     
    201           basic_doc_list.appendChild(current_doc);
     203
    202204          if (document_type == null) {
    203               document_type = getDocumentType(basic_doc_list, collection, userContext, page_response);
     205            Element basic_doc_list = doc.createElement(GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER);
     206            Element current_doc = doc.createElement(GSXML.DOC_NODE_ELEM);
     207            basic_doc_list.appendChild(current_doc);
     208            current_doc.setAttribute(GSXML.NODE_ID_ATT, document_id);
     209            basic_doc_list.appendChild(current_doc);
     210            document_type = getDocumentType(basic_doc_list, collection, userContext, page_response);
    204211          }
     212         
    205213          if (document_type == null) {
    206214              logger.debug("@@@ doctype is null, setting to simple");
    207215              document_type = GSXML.DOC_TYPE_SIMPLE;
    208216          }       
    209          
    210           Element doc_elem = doc.createElement(GSXML.DOCUMENT_ELEM);         
     217
     218          Element doc_elem = doc.createElement(GSXML.DOCUMENT_ELEM);   
    211219          doc_elem.setAttribute(GSXML.DOC_TYPE_ATT, document_type);
    212220          page_response.appendChild(doc_elem);
    213           section.setAttribute(GSXML.NODE_ID_ATT, document_id);
    214 
    215        
     221
    216222          Element transformed_section = transformArchiveToDocument(section);
     223          if (document_type ==  GSXML.DOC_TYPE_SIMPLE) {
     224            // simple doc, only returning a single document node, which is the top level section.
     225            doc_elem.setAttribute(GSXML.NODE_ID_ATT, document_id);
     226            GSXML.mergeElements(doc_elem, transformed_section);
     227            return result;
     228          }
     229
     230          // multi sectioned document.
     231          transformed_section.setAttribute(GSXML.NODE_ID_ATT, document_id);       
    217232          // In docEdit mode, we obtain the text from archives, from doc.xml
    218233          // Now the transformation has replaced <Section> with <documentNode>
Note: See TracChangeset for help on using the changeset viewer.