Ignore:
Timestamp:
2023-03-16T19:42:42+13:00 (14 months ago)
Author:
kjdon
Message:

usign the new GetRequiredMEtadataNames - has an extra arg, and we no longer need to do teh extraMEtadataList bit ourselves, as its now in getRequiredMetadataNames

File:
1 edited

Legend:

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

    r31873 r37514  
    126126        // add the format info into the response
    127127        Element format_elem = (Element) GSXML.getChildByTagName(format_response, GSXML.FORMAT_ELEM);
     128                Element this_format = null;
    128129        if (format_elem != null)
    129130        {
    130             // find the one for the classifier we are in
    131             Element this_format = GSXML.getNamedElement(format_elem, GSXML.CLASSIFIER_ELEM, GSXML.NAME_ATT, top_id);
    132             if (this_format == null)
    133             {
    134                 this_format = (Element) GSXML.getChildByTagName(format_elem, GSXML.DEFAULT_ELEM);
    135             }
    136 
    137             if (this_format != null)
    138             {
    139                 Element global_format_elem = (Element) GSXML.getChildByTagName(format_response, GSXML.GLOBAL_FORMAT_ELEM);
    140                 if (global_format_elem != null)
    141                 {
    142                     GSXSLT.mergeFormatElements(this_format, global_format_elem, false);
    143                 }
    144 
    145                 Element new_format = GSXML.duplicateWithNewName(doc, this_format, GSXML.FORMAT_ELEM, false);
    146                 extractMetadataNames(new_format, doc_meta_names, class_meta_names);
    147 
    148                 Element extraMetaListElem = (Element) GSXML.getChildByTagName(request, GSXML.EXTRA_METADATA + GSXML.LIST_MODIFIER);
    149                 if (extraMetaListElem != null)
    150                 {
    151                     NodeList extraMetaList = extraMetaListElem.getElementsByTagName(GSXML.EXTRA_METADATA);
    152                     for (int i = 0; i < extraMetaList.getLength(); i++)
    153                     {
    154                         doc_meta_names.add(((Element) extraMetaList.item(i)).getAttribute(GSXML.NAME_ATT));
    155                     }
    156                 }
     131                  // find the one for the classifier we are in
     132                  this_format = GSXML.getNamedElement(format_elem, GSXML.CLASSIFIER_ELEM, GSXML.NAME_ATT, top_id);
     133                  if (this_format == null)
     134                  {
     135                    this_format = (Element) GSXML.getChildByTagName(format_elem, GSXML.DEFAULT_ELEM);
     136                  }
     137
     138                  if (this_format != null)
     139                  {
     140                    Element global_format_elem = (Element) GSXML.getChildByTagName(format_response, GSXML.GLOBAL_FORMAT_ELEM);
     141                    if (global_format_elem != null)
     142                    {
     143                      GSXSLT.mergeFormatElements(this_format, global_format_elem, false);
     144                    }
     145                   
     146                    Element new_format = GSXML.duplicateWithNewName(doc, this_format, GSXML.FORMAT_ELEM, false);
     147                    // set the format type
     148                    new_format.setAttribute(GSXML.TYPE_ATT, "browse");
     149                   
     150                    page_response.appendChild(new_format);
     151                   
     152                  }
    157153               
    158                 // set the format type
    159                 new_format.setAttribute(GSXML.TYPE_ATT, "browse");
    160 
    161                 page_response.appendChild(new_format);
    162             }
    163         }
    164 
    165         // find out if this classifier is horizontal at top
     154           
     155                }
     156                extractMetadataNames(doc_meta_names, class_meta_names, this_format, request);
     157
     158                // find out if this classifier is horizontal at top
    166159        Element class_list = (Element) GSXML.getChildByTagName(service_description, GSXML.CLASSIFIER_ELEM + GSXML.LIST_MODIFIER);
    167160        Element this_classifier = GSXML.getNamedElement(class_list, GSXML.CLASSIFIER_ELEM, GSXML.NAME_ATT, top_id);
     
    481474    }
    482475
    483     protected void extractMetadataNames(Element new_format, HashSet<String> doc_meta_names, HashSet<String> class_meta_names)
     476  protected void extractMetadataNames(HashSet<String> doc_meta_names, HashSet<String> class_meta_names, Element new_format, Element request)
    484477    {
     478          // for doc names, add the ones from extraMetadata
     479          getRequiredMetadataNames(doc_meta_names, null, request);
     480         
    485481        NodeList templates = new_format.getElementsByTagNameNS(GSXML.GSF_NAMESPACE, "template");
    486482        for (int i = 0; i < templates.getLength(); i++)
     
    493489                if (match.startsWith("documentNode"))
    494490                {
    495                     getRequiredMetadataNames(template, doc_meta_names);
     491                                  getRequiredMetadataNames(doc_meta_names, template, null);
    496492                }
    497493                else if (match.startsWith("classifierNode")) // not match.equals, as we want to match nodes like: classifierNode[@classifierStyle = 'VList']
    498494                {
    499                     getRequiredMetadataNames(template, class_meta_names);
     495                                  getRequiredMetadataNames(class_meta_names, template, null);
    500496                }
    501497            }
    502498            else
    503499            {
    504                 getRequiredMetadataNames(template, doc_meta_names);
    505                 getRequiredMetadataNames(template, class_meta_names);
     500                          getRequiredMetadataNames(doc_meta_names, template, null);
     501                          getRequiredMetadataNames(class_meta_names, template, null);
    506502            }
    507503        }
Note: See TracChangeset for help on using the changeset viewer.