Changeset 23419


Ignore:
Timestamp:
2010-12-09T00:10:10+13:00 (13 years ago)
Author:
max
Message:

Setting the values to store as block files is now done through an API call to BasePlugin. This way, anything uniform requirement (such as putting in both C:\... and c:\... entries for Windows) can be done in one place.

Location:
main/trunk/greenstone2/perllib/plugins
Files:
10 edited

Legend:

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

    r23212 r23419  
    202202    my ($filename_full_path, $filename_no_path)
    203203        = &util::get_full_filenames($base_dir, $file);
    204     $block_hash->{'file_blocks'}->{$filename_full_path} = 1;
     204    $self->block_filename($block_hash,$filename_full_path);
    205205    return 1;
    206206    }
  • main/trunk/greenstone2/perllib/plugins/BasePlugin.pm

    r23418 r23419  
    382382}
    383383
     384sub block_filename
     385{
     386    my $self = shift(@_);
     387    my ($block_hash,$filename) = @_;
     388   
     389    if ($ENV{'GSDLOS'} =~ m/^windows$/) {
     390       
     391        my $lower_drive = $filename;
     392        $lower_drive =~ s/^([A-Z]):/\l$1:/i;
     393       
     394        my $upper_drive = $filename;
     395        $upper_drive =~ s/^([A-Z]):/\u$1:/i;
     396       
     397        $block_hash->{'file_blocks'}->{$lower_drive} = 1;
     398        $block_hash->{'file_blocks'}->{$upper_drive} = 1;       
     399    }
     400    else {
     401        $block_hash->{'file_blocks'}->{$filename} = 1;
     402    }
     403}
     404
    384405# rename imported files and assoc files using URL encoding by default
    385406# as this will work for most plugins and give more legible filenames
     
    417438
    418439    if ($self->{'block_exp'} ne "" && $filename_full_path =~ /$self->{'block_exp'}/) {
    419     $block_hash->{'file_blocks'}->{$filename_full_path} = 1;
     440    $self->block_filename($block_hash,$filename_full_path);
    420441    }
    421442
     
    437458    }   
    438459    if (&util::fd_exists($coverfile)) {
    439         $block_hash->{'file_blocks'}->{$coverfile} = 1;
     460        $self->block_filename($block_hash,$coverfile);
    440461    }
    441462    }
     
    11691190    my ($textref, $pluginfo, $base_dir, $file, $metadata, $doc_obj, $gli) = @_;
    11701191
    1171     gsprintf(STDERR, "BasePlugin::process {common.must_be_implemented}\n") && die "\n";
     1192    gsprintf(STDERR, "BasePlugin::process {common.must_be_implemented}\n");
     1193
     1194    my ($cpackage,$cfilename,$cline,$csubr,$chas_args,$cwantarray) = caller(1);
     1195    print STDERR "Calling method: $cfilename:$cline $cpackage->$csubr\n";
     1196
     1197    die "\n";
    11721198
    11731199    return undef; # never gets here
  • main/trunk/greenstone2/perllib/plugins/DSpacePlugin.pm

    r23212 r23419  
    148148    my $handle_filename = &util::filename_cat($contents_basedir,"handle");
    149149
    150     $block_hash->{'file_blocks'}->{$handle_filename} = 1 if (-e $handle_filename);
     150    if (&util::fd_exists($handle_filename)) {
     151    $self->block_filename($block_hash,$handle_filename);
     152    }
    151153}
    152154
  • main/trunk/greenstone2/perllib/plugins/DirectoryPlugin.pm

    r23363 r23419  
    235235        foreach my $e (keys %$exts) {
    236236        # block the file
    237         $block_hash->{'file_blocks'}->{"$prefix$e"} = 1;
     237        $self->block_filename($block_hash,"$prefix$e");
    238238        # set up as an associatd file
    239239        print STDERR "  $self->{'plugin_type'}: Associating $prefix$e with $tie_to version\n";
     
    333333    $self->sort_out_associated_files($block_hash);
    334334    #return $count;
     335    return 1;
    335336   
    336337}
  • main/trunk/greenstone2/perllib/plugins/GreenstoneXMLPlugin.pm

    r23212 r23419  
    123123        }
    124124
    125         $block_hash->{'file_blocks'}->{$full_gsdl_assoc_filename} = 1;
     125        $self->block_filename($block_hash,$full_gsdl_assoc_filename);       
    126126        }
    127127    }
  • main/trunk/greenstone2/perllib/plugins/HTMLPlugin.pm

    r23418 r23419  
    281281
    282282        # Allow for possibility of raw byte version and Unicode versions of file
    283         $block_hash->{'file_blocks'}->{$unicode_url_original_filename} = 1;
    284 
     283        $self->block_filename($block_hash,$unicode_url_original_filename);
    285284    }
    286285
    287286    # $url_original_filename = &util::upgrade_if_dos_filename($url_original_filename);
    288287   
    289    
    290     $block_hash->{'file_blocks'}->{$url_original_filename} = 1;
    291     if ($ENV{'GSDLOS'} =~ m/^windows$/) {
    292        
    293         my $lower_drive = $url_original_filename;
    294         $lower_drive =~ s/^([A-Z]):/\l$1:/i;
    295         my $upper_drive = $url_original_filename;
    296        
    297         $upper_drive =~ s/^([A-Z]):/\u$1:/i;
    298 
    299 ##      print STDERR "**** HTML plugin, blocking: \"$lower_drive\"\n";
    300 ##      print STDERR "**** HTML plugin, blocking: \"$upper_drive\"\n";
    301        
    302         $block_hash->{'file_blocks'}->{$lower_drive} = 1;
    303         $block_hash->{'file_blocks'}->{$upper_drive} = 1;       
    304     }
    305     else {
    306 ##      print STDERR "**** HTML plugin, blocking: $url_original_filename\n";
    307         $block_hash->{'file_blocks'}->{$url_original_filename} = 1;
    308     }
     288    $self->block_filename($block_hash,$url_original_filename);
    309289       
    310290    }
  • main/trunk/greenstone2/perllib/plugins/ISISPlugin.pm

    r20778 r23419  
    136136    print STDERR "$self->{'fdt_file_path'}\n";
    137137    my $fdt_file = $self->{'fdt_file_path'};
    138     $block_hash->{'file_blocks'}->{$fdt_file} = 1;
     138    $self->block_filename($block_hash,$fdt_file);
    139139    }
    140140    if (-e $self->{'xrf_file_path'}) {
    141141    print STDERR "$self->{'xrf_file_path'}\n";
    142142    my $xrf_file = $self->{'xrf_file_path'};
    143     $block_hash->{'file_blocks'}->{$xrf_file} = 1;
     143    $self->block_filename($block_hash,$xrf_file);
    144144    }
    145145   
  • main/trunk/greenstone2/perllib/plugins/MetadataCSVPlugin.pm

    r23212 r23419  
    113113
    114114    # add the file to the block list so that it won't be processed in read, as we will do all we can with it here
    115     $block_hash->{'file_blocks'}->{$filename} = 1;
     115    $self->block_filename($block_hash,$filename);
    116116
    117117    # Read the CSV file to get the metadata
  • main/trunk/greenstone2/perllib/plugins/MetadataXMLPlugin.pm

    r23212 r23419  
    214214    my $self = shift (@_);
    215215    my ($pluginfo, $base_dir, $file, $block_hash, $metadata, $gli) = @_;
    216 
     216   
    217217    my $filename_full_path = &util::filename_cat($base_dir, $file);
    218218    return undef unless $self->can_process_this_file($filename_full_path);   
    219219
    220     $block_hash->{'metadata_files'}->{$filename_full_path} = 1;
     220    if ($ENV{'GSDLOS'} =~ m/^windows$/) {
     221       
     222        my $lower_drive = $filename_full_path;
     223        $lower_drive =~ s/^([A-Z]):/\l$1:/i;
     224       
     225        my $upper_drive = $filename_full_path;
     226        $upper_drive =~ s/^([A-Z]):/\u$1:/i;
     227       
     228        $block_hash->{'metadata_files'}->{$lower_drive} = 1;
     229        $block_hash->{'metadata_files'}->{$upper_drive} = 1;       
     230    }
     231    else {
     232        $block_hash->{'metadata_files'}->{$filename_full_path} = 1;
     233    }
    221234
    222235    return 1;
     
    235248    $self->{'metadata-file'} = $file;
    236249    $self->{'metadata-filename'} = $filename;
    237 
     250   
    238251    my $outhandle = $self->{'outhandle'};
    239252   
     
    241254    print $outhandle "MetadataXMLPlugin: processing $file\n" if ($self->{'verbosity'})> 1;
    242255    # add the file to the block list so that it won't be processed in read, as we will do all we can with it here
    243     $block_hash->{'file_blocks'}->{$filename} = 1;
     256    $self->block_filename($block_hash,$filename);
    244257
    245258    $self->{'metadataref'} = $extrametadata;
  • main/trunk/greenstone2/perllib/plugins/PagedImagePlugin.pm

    r23363 r23419  
    576576
    577577    if ($line =~ /imgfile=\"([^\"]+)\"/) {
    578         $block_hash->{'file_blocks'}->{$dir.$1} = 1;
     578        $self->block_filename($block_hash,$dir.$1);
    579579    }
    580580    if ($line =~ /txtfile=\"([^\"]+)\"/) {
    581         $block_hash->{'file_blocks'}->{$dir.$1} = 1;
     581        $self->block_filename($block_hash,$dir.$1);
    582582    }
    583583    }
     
    605605    # find the image file if there is one
    606606    if (defined $imgname && $imgname ne "") {
    607         $block_hash->{'file_blocks'}->{$dir.$imgname}=1;
     607        $self->block_filename($block_hash,$dir.$imgname);
    608608    }
    609609    # find the text file if there is one
    610610    if (defined $txtname && $txtname ne "") {
    611         $block_hash->{'file_blocks'}->{$dir.$txtname} = 1;
     611        $self->block_filename($block_hash,$dir.$txtname);
    612612    }
    613613    }
Note: See TracChangeset for help on using the changeset viewer.