Changeset 6639


Ignore:
Timestamp:
2004-01-28T14:47:07+13:00 (20 years ago)
Author:
jmt12
Message:

Prevent hand entered section metadata being extracted in the same way that the top level metadata is

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/msm/GreenstoneArchiveParser.java

    r6539 r6639  
    108108        String file_path = null;
    109109        Element archive_element = document.getDocumentElement();
     110        // Retrieve the initial Section element
     111        NodeList section_elements = archive_element.getElementsByTagName(StaticStrings.SECTION_ELEMENT);
     112        // It may be the case that we have some sort of mutant freak archive file which doesn't have any section elements.
     113        if(section_elements.getLength() < 1) {
     114        return count;
     115        }
     116        Element section_element = (Element) section_elements.item(0);       
     117        section_elements = null;
    110118        // Retrieve all of the Metadata sections.
    111         NodeList metadata_elements = archive_element.getElementsByTagName("Metadata");
     119        NodeList metadata_elements = section_element.getElementsByTagName(StaticStrings.METADATA_ELEMENT);
     120        section_element = null;
    112121        // We first zip through the retrieved metadata, and if we encounter the element 'SourceSegment' - a sure sign this collection came from a bibliographic type file - we break out of extracted metadata parsing as no sense could be made of the data extracted anyway (plus we suffer a death of thirty-thousand pointy bits of metadata!)
    113122        for(int i = 0; i < metadata_elements.getLength(); i++) {
    114123        Element metadata_element = (Element) metadata_elements.item(i);
    115         String name = metadata_element.getAttribute("name");
     124        String name = metadata_element.getAttribute(StaticStrings.NAME_ATTRIBUTE);
    116125        if(name.equalsIgnoreCase(StaticStrings.SOURCESEGMENT_VALUE)) {
    117126            return 0;
     
    121130        for(int i = 0; i < metadata_elements.getLength(); i++) {
    122131        Element metadata_element = (Element) metadata_elements.item(i);
    123         String name = metadata_element.getAttribute("name");
     132        String name = metadata_element.getAttribute(StaticStrings.NAME_ATTRIBUTE);
    124133        // There is also a special case when the metadata name is gsdlsourcefilename, as we use this to find the FileRecord we want to add metadata to.
    125134        if(name.equals("gsdlsourcefilename")) {
Note: See TracChangeset for help on using the changeset viewer.