Changeset 25333

Show
Ignore:
Timestamp:
03.04.2012 12:29:15 (8 years ago)
Author:
kjdon
Message:

added some output messages. make sure we keep previous metadata - there may be metadata for a file from a previous plugin, not just from OAIPlugin

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/perllib/plugins/OAIPlugin.pm

    r24971 r25333  
    200200    my ($filename_full_path, $filename_no_path) = &util::get_full_filenames($base_dir, $file); 
    201201    return undef unless $self->can_process_this_file_for_metadata($filename_full_path); 
     202 
     203    print STDERR "\n<Processing n='$file' p='OAIPlugin'>\n" if ($gli); 
     204    print STDERR "OAIPlugin: processing $file\n" if ($self->{'verbosity'}) > 1; 
    202205     
    203206    if (!$self->parse_file($filename_full_path, $file, $gli)) { 
     
    206209    } 
    207210 
     211    my $verbosity = $self->{'verbosity'}; 
    208212    my $new_metadata = $self->{'saved_metadata'}; 
    209213    $self->{'saved_metadata'} = undef; 
     
    263267    $filename_for_metadata = &util::filepath_to_url_format($filename_for_metadata); 
    264268    $filename_for_metadata = &util::filename_to_regex($filename_for_metadata); 
    265      
    266     &extrametautil::setmetadata($extrametadata, $filename_for_metadata, $new_metadata); 
    267     &extrametautil::addmetakey($extrametakeys, $filename_for_metadata); 
     269 
     270    # Check that we haven't already got some metadata 
     271    if (defined &extrametautil::getmetadata($extrametadata, $filename_for_metadata)) { 
     272    print STDERR "\n****  OAIPlugin: Need to merge new metadata with existing stored metadata: file = $filename_for_metadata\n" if $verbosity > 3; 
     273 
     274    my $file_metadata_table = &extrametautil::getmetadata($extrametadata, $filename_for_metadata); 
     275 
     276    foreach my $metaname (keys %{$new_metadata}) { 
     277        # will create new entry if one does not already exist 
     278        push(@{$file_metadata_table->{$metaname}}, @{$new_metadata->{$metaname}});       
     279    } 
     280 
     281    } else { 
     282    &extrametautil::setmetadata($extrametadata, $filename_for_metadata, $new_metadata); 
     283    &extrametautil::addmetakey($extrametakeys, $filename_for_metadata); 
     284    } 
     285 
    268286    if ($srcdoc_exists) {    
    269287    if (!defined &extrametautil::getmetafile($extrametafile, $filename_for_metadata)) {