Changeset 8515


Ignore:
Timestamp:
2004-11-11T14:20:55+13:00 (19 years ago)
Author:
chi
Message:

Add a new method metadata_read to identify any specific or extra metadata sets.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/perllib/plugin.pm

    r7904 r8515  
    105105}
    106106
    107 sub read {
    108     my ($pluginfo, $base_dir, $file, $metadata, $processor, $maxdocs, $gli, $aux) = @_;
    109  
     107sub metadata_read {
     108    my ($pluginfo, $base_dir, $file, $metadata, $extrametakeys, $extrametadata, $processor, $maxdocs, $gli, $aux) = @_;
    110109
    111110    $maxdocs = -1 unless defined $maxdocs && $maxdocs =~ /\d/;
    112111    $gli = 0 unless defined $gli;
    113112
    114  
    115113    my $rv = 0;
    116114    my $glifile = $file;
    117115   
    118116    $glifile =~ s/^[\/\\]+//; # file sometimes starts with a / so get rid of it
     117   
    119118    # Announce to GLI that we are handling a file
    120119    print STDERR "<File n='$glifile'>\n" if $gli;
    121 
    122  
     120   
    123121    # the .kill file is a handy (if not very elegant) way of aborting
    124122    # an import.pl or buildcol.pl process
     
    127125    die "\n";
    128126    }
    129    
     127
    130128    my $had_error = 0;
    131129    # pass this file by each of the plugins in turn until one
     
    136134    # 0 - blocked
    137135    # anything else for successful processing
     136   
    138137    foreach my $plugobj (@$pluginfo) {
    139     $rv = $plugobj->read($pluginfo, $base_dir, $file,
     138
     139    $rv = $plugobj->metadata_read($pluginfo, $base_dir, $file,
     140                 $metadata, $extrametakeys, $extrametadata, $processor, $maxdocs, $gli, $aux);
     141
     142    if (defined $rv) {
     143        if ($rv == -1) {
     144            # an error has occurred
     145        $had_error = 1;
     146        print STDERR "<ProcessingError n='$glifile'>\n" if $gli;
     147        } else {
     148            return $rv;
     149        }
     150    } # else undefined - was not recognised by the plugin
     151    }
     152
     153    return 0;
     154}
     155
     156sub read {
     157    my ($pluginfo, $base_dir, $file, $metadata, $processor, $maxdocs, $gli, $aux) = @_;
     158
     159    $maxdocs = -1 unless defined $maxdocs && $maxdocs =~ /\d/;
     160    $gli = 0 unless defined $gli;
     161
     162    my $rv = 0;
     163    my $glifile = $file;
     164   
     165    $glifile =~ s/^[\/\\]+//; # file sometimes starts with a / so get rid of it
     166   
     167    # Announce to GLI that we are handling a file
     168    print STDERR "<File n='$glifile'>\n" if $gli;
     169   
     170    # the .kill file is a handy (if not very elegant) way of aborting
     171    # an import.pl or buildcol.pl process
     172    if (-e &util::filename_cat ($ENV{'GSDLCOLLECTDIR'}, ".kill")) {
     173    gsprintf($outhandle, "{plugin.kill_file}\n");
     174    die "\n";
     175    }
     176
     177    my $had_error = 0;
     178    # pass this file by each of the plugins in turn until one
     179    # is found which will process it
     180    # read must return:
     181    # undef - could not recognise
     182    # -1 - tried but error
     183    # 0 - blocked
     184    # anything else for successful processing
     185   
     186    foreach my $plugobj (@$pluginfo) {
     187
     188        $rv = $plugobj->read($pluginfo, $base_dir, $file,
    140189                 $metadata, $processor, $maxdocs, $gli, $aux);
    141         if (defined $rv) {
     190
     191    if (defined $rv) {
    142192        if ($rv == -1) {
    143193            # an error has occurred
     
    173223    $stats->{'num_not_recognised'} ++;
    174224    }
    175 
    176225    return 0;
    177226}
Note: See TracChangeset for help on using the changeset viewer.