Changeset 31966 for main

Show
Ignore:
Timestamp:
14.09.2017 14:28:36 (2 years ago)
Author:
kjdon
Message:

metadata prefix elements don't change, so don't need to create it each time we are asked for metadata. Create them initially and store in a map with prefix, then just use it.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/OAIPMH.java

    r31912 r31966  
    6969  protected HashMap<String, HashSet<String>> format_elements_map = null; 
    7070  protected HashMap<String, Element> format_response_map = null; 
     71  protected HashMap<String, Element> format_meta_elem_map = null; 
     72   
    7173  /** constructor */ 
    7274  public OAIPMH() { 
     
    192194    this.format_response_map = new HashMap<String, Element>(); 
    193195    this.format_elements_map = new HashMap<String, HashSet<String>>(); 
     196    this.format_meta_elem_map = new HashMap<String, Element>(); 
    194197 
    195198    // for now, all we want is the metadata prefix description and the mapping list 
     
    204207      return false; 
    205208    } 
     209     
    206210    boolean found_meta_format = false; 
    207211    for(int i=0; i<meta_formats_list.getLength(); i++) { 
     
    218222    continue; 
    219223      } 
     224       
    220225      // copy the format definition into our stored Element 
    221226      Element collection_version_format = (Element) this.desc_doc.importNode(meta_format, true); 
     
    228233      // now set up a list of all collection elements for reverse lookup of the mapping 
    229234      format_elements_map.put(prefix, getAllCollectionElements(collection_version_format)); 
     235      format_meta_elem_map.put(prefix, OAIXML.getMetadataPrefixElement(this.desc_doc, prefix, collection_version_format)); 
    230236       
    231237    } 
     
    650656    Element metadata = doc.createElement(OAIXML.METADATA); 
    651657    // the <oai:dc namespace...> element 
    652     Element prfx_str_elem = OAIXML.getMetadataPrefixElement(doc, prefix, OAIXML.oai_version); 
     658    Element prfx_str_elem = (Element)doc.importNode(this.format_meta_elem_map.get(prefix), true);  
    653659    metadata.appendChild(prfx_str_elem); 
    654  
     660     
    655661    Element meta_format_element = GSXML.getNamedElement(this.meta_formats_definition, OAIXML.METADATA_FORMAT, GSXML.NAME_ATT, prefix); 
    656662    NodeList elements = meta_format_element.getElementsByTagName(OAIXML.ELEMENT);