Changeset 29521


Ignore:
Timestamp:
2014-12-03T12:39:28+13:00 (9 years ago)
Author:
kjdon
Message:

get the format element and look for parameter defaults in it. If we have a simple doc, and have a dummy doc (could be if ed=1 has been set as a default for the collection), then remove the dummy node.

File:
1 edited

Legend:

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

    r29439 r29521  
    120120            return result;
    121121        }
     122
     123        UserContext userContext = new UserContext(request);
     124
     125        //append site metadata
     126        addSiteMetadata(page_response, userContext);
     127        addInterfaceOptions(page_response);
     128
     129        // get the additional data needed for the page
     130        getBackgroundData(page_response, collection, userContext);
     131        Element format_elem = (Element) GSXML.getChildByTagName(page_response, GSXML.FORMAT_ELEM);
     132
     133        if (format_elem != null) {
     134          // lets look for param defaults set in config file
     135          NodeList param_defaults = format_elem.getElementsByTagName("paramDefault");
     136          for (int i=0; i<param_defaults.getLength(); i++) {
     137            Element p = (Element)param_defaults.item(i);
     138            String name = p.getAttribute(GSXML.NAME_ATT);
     139            if (params.get(name) ==null) {
     140              // wasn't set from interface
     141              String value = p.getAttribute(GSXML.VALUE_ATT);
     142              params.put(name, value );
     143              // also add into request param xml so that xslt knows it too
     144              GSXML.addParameterToList(cgi_paramList, name, value);
     145            }
     146          }
     147        }
    122148        String document_type = (String) params.get(GSParams.DOCUMENT_TYPE);
    123149        if (document_type != null && document_type.equals(""))
     
    163189        }
    164190
    165         UserContext userContext = new UserContext(request);
    166 
    167         //append site metadata
    168         addSiteMetadata(page_response, userContext);
    169         addInterfaceOptions(page_response);
    170 
    171         // get the additional data needed for the page
    172         getBackgroundData(page_response, collection, userContext);
    173         Element format_elem = (Element) GSXML.getChildByTagName(page_response, GSXML.FORMAT_ELEM);
     191        // UserContext userContext = new UserContext(request);
     192
     193        // //append site metadata
     194        // addSiteMetadata(page_response, userContext);
     195        // addInterfaceOptions(page_response);
     196
     197        // // get the additional data needed for the page
     198        // getBackgroundData(page_response, collection, userContext);
     199        // Element format_elem = (Element) GSXML.getChildByTagName(page_response, GSXML.FORMAT_ELEM);
    174200
    175201        // the_document is where all the doc info - structure and metadata etc
     
    521547                }
    522548                //GSXML.mergeMetadataLists(doc_nodes.item(i), dm_response_docs.item(i));
     549            }
     550            if (has_dummy && document_type.equals(GSXML.DOC_TYPE_SIMPLE)) {
     551              Element dummy_node = (Element) doc_nodes.item(0);
     552              the_document.removeChild(dummy_node);
     553              the_document.setAttribute(GSXML.NODE_ID_ATT, dummy_node.getAttribute(GSXML.NODE_ID_ATT));
     554              NodeList dummy_children = dummy_node.getChildNodes();
     555              for (int i = dummy_children.getLength() - 1; i >= 0; i--)
     556                {
     557                  // special case as we don't want more than one metadata list
     558                  if (dummy_children.item(i).getNodeName().equals(GSXML.METADATA_ELEM + GSXML.LIST_MODIFIER))
     559                {
     560                  GSXML.mergeMetadataFromList(the_document, dummy_children.item(i));
     561                }
     562                  else
     563                {
     564                  the_document.appendChild(dummy_children.item(i));
     565                }
     566                }
    523567            }
    524568        }
Note: See TracChangeset for help on using the changeset viewer.