Changeset 6172


Ignore:
Timestamp:
2003-12-08T17:04:53+13:00 (20 years ago)
Author:
jmt12
Message:

Fixed bug where deleting one entry caused all metadata to be removed (was actually thinking the parent node was empty and removing it)

File:
1 edited

Legend:

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

    r6158 r6172  
    437437    return ((doctype_name.equals("GreenstoneDirectoryMetadata") && root_name.equals("GreenstoneDirectoryMetadata")) || (doctype_name.equals("DirectoryMetadata") && root_name.equals("DirectoryMetadata")));
    438438    }
    439     /** Remove the given directory level metadata from this document. All directory level metadata is available under the FileSet with filename '.*'. There is at least one nasty case to consider, where the first overwriting metadata entry, of several with the same element, is removed. In this case the next entry must become overwrite to ensure proper inheritance. */
    440     public void removeMetadata(String filename, Metadata metadata) {
     439    /** Remove the given directory level metadata from this document. All directory level metadata is available under the FileSet with filename '.*'. There is at least one nasty case to consider, where the first overwriting metadata entry, of several with the same element, is removed. In this case the next entry must become overwrite to ensure proper inheritance. */
     440    public void removeMetadata(String filename, Metadata metadata) {
    441441    Gatherer.println("Remove metadata: " + metadata + "\nFrom filename: " + filename);
    442442    try {
     
    470470                     if(element.equals(metadata.getElement().getName())) {
    471471                         if(value.equals(metadata.getAbsoluteValue())) {
    472                          // Remove it
    473                          ///ystem.err.println("Remove " + element + "-" + value);
     472                             // Remove it
     473                             ///ystem.err.println("Remove " + element + "-" + value);
    474474                         description_element.removeChild(metadata_element);
    475475                         found = true;
     
    495495                     metadata_element = null;
    496496                     }
    497                      metadata_elements = description_element.getElementsByTagName(ALL_METADATA_TYPES[z]);
     497                     NodeList normal_metadata_elements = description_element.getElementsByTagName(ALL_METADATA_TYPES[0]);
     498                     NodeList extracted_metadata_elements = description_element.getElementsByTagName(ALL_METADATA_TYPES[1]);
    498499                     // If we found it, removed it, and now the description tag has no children, mark the fileset for removal
    499                      if(metadata_elements.getLength() == 0) {
    500                      remove_fileset = true;
     500                     if(normal_metadata_elements.getLength() == 0 && extracted_metadata_elements.getLength() == 0) {
     501                         remove_fileset = true;
    501502                     }
     503                     extracted_metadata_elements = null;
     504                     normal_metadata_elements = null;
    502505                     metadata_elements = null;
    503506                }
Note: See TracChangeset for help on using the changeset viewer.