Changeset 14245


Ignore:
Timestamp:
2007-07-12T11:05:39+12:00 (17 years ago)
Author:
xiao
Message:

pass the flag disable_OAI to the write_build_cfg_xml sub instead of hacking into the structure which causes regular expression compilation errors when writing the build.cfg file (since the flag has nothing to do with Greenstone 2 hence the build.cfg file). Plus restore the file back to sjboddie's revision 14112.

File:
1 edited

Legend:

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

    r14212 r14245  
    2626package basebuilder;
    2727
     28use strict;
     29no strict 'refs'; # allow filehandles to be variables and viceversa
     30
    2831use classify;
    2932use cfgread;
     
    5659    $outhandle, $no_text, $failhandle, $gli, $disable_OAI) = @_;
    5760
    58     $outhandle = STDERR unless defined $outhandle;
     61    $outhandle = *STDERR unless defined $outhandle;
    5962    $no_text = 0 unless defined $no_text;
    60     $failhandle = STDERR unless defined $failhandle;
     63    $failhandle = *STDERR unless defined $failhandle;
    6164
    6265    # create a builder object
     
    8083
    8184    $self->{'gli'} = 0 unless defined $self->{'gli'};
     85   
     86    # disable_OIA applies to greenstone 3 only and is only passed to &colcfg::write_build_cfg_xml (then cfgread4gs3::write_cfg_file) when writing the buildConfig.xml
    8287    $self->{'disable_OAI'} = 0 unless defined $self->{'disable_OAI'};
    83    
    84     # read in the collection configuration file
    85     my $colcfgname = "$ENV{'GSDLCOLLECTDIR'}/etc/collect.cfg";
    86     if (-e $colcfgname) {
    87       ##$self->{'collect_cfg'} = &colcfg::read_collection_cfg_xml ($colcfgname);
    88       $self->{'collect_cfg'} = &colcfg::read_collect_cfg ($colcfgname);
    89       $gs_mode = "gs2";
    90     }
    91     else {
    92       my $colcfgname = "$ENV{'GSDLCOLLECTDIR'}/etc/collectionConfig.xml";
    93       if (!-e $colcfgname) {
    94     die "mgbuilder::new - couldn't find collectionConfig.xml for collection $collection\n";
    95       }
    96       else {
    97     #$self->{'collect_cfg'} = &colcfg::read_collect_cfg ($colcfgname);
    98         $self->{'collect_cfg'} = &colcfg::read_collection_cfg_xml ($colcfgname);
    99     $gs_mode = "gs3";
    100       }
     88
     89    # Read in the collection configuration file.
     90    my ($colcfgname);
     91    ($colcfgname, $gs_mode) = &colcfg::get_collect_cfg_name($outhandle);
     92    if ($gs_mode eq "gs2") {
     93        $self->{'collect_cfg'} = &colcfg::read_collect_cfg ($colcfgname);
     94    } elsif ($gs_mode eq "gs3") {
     95    $self->{'collect_cfg'} = &colcfg::read_collection_cfg_xml ($colcfgname);
    10196    }
    10297   
     
    196191    my ($buildprocdir, $buildproctype);
    197192    my $collection = $self->{'collection'};
    198     if (-e "$ENV{'GSDLCOLLECTDIR'}/perllib/${collection}buildproc.pm") {
     193    if (-e "$ENV{'GSDLCOLLECTDIR'}/custom/${collection}/perllib/custombuildproc.pm") {
     194    $buildprocdir = "$ENV{'GSDLCOLLECTDIR'}/custom/${collection}/perllib";
     195    $buildproctype = "custombuildproc";
     196    } elsif (-e "$ENV{'GSDLCOLLECTDIR'}/perllib/custombuildproc.pm") {
     197    $buildprocdir = "$ENV{'GSDLCOLLECTDIR'}/perllib";
     198    $buildproctype = "custombuildproc";
     199    } elsif (-e "$ENV{'GSDLCOLLECTDIR'}/perllib/${collection}buildproc.pm") {
    199200    $buildprocdir = "$ENV{'GSDLCOLLECTDIR'}/perllib";
    200201    $buildproctype = "${collection}buildproc";
     
    240241    $self->{'maxnumeric'} = $maxnumeric;
    241242}
    242 # It seems we don't need this sub
    243 #sub set_disable_OAI {
    244 #    my $disable_OAI = shift (@_);
    245 #    my ($disable_OAI = @_;
    246 #
    247 #    $self->{'disable_OAI'} = $disable_OAI;
    248 #}
    249243sub set_strip_html {
    250244    my $self = shift (@_);
     
    279273    # and their directory names (includes subcolls and langs)
    280274    $self->{'index_mapping'} = $self->create_index_mapping ($indexes);
    281 
    282     my $indexmap = $self->{'index_mapping'}->{'indexmap'};
    283 
     275   
    284276    # build each of the indexes
    285277    foreach my $index (@$indexes) {
     
    351343    my ($handle);
    352344    if ($self->{'debug'}) {
    353     $handle = STDOUT;
     345    $handle = *STDOUT;
    354346    } else {
    355347    if (!-e "$txt2db_exe" || !open (PIPEOUT, "| txt2db$exe \"$fulldbname\"")) {
     
    357349        die "builder::make_infodatabase - couldn't run $txt2db_exe\n";
    358350    }
    359     $handle = basebuilder::PIPEOUT;
     351    $handle = *PIPEOUT;
    360352    }
    361353   
     
    439431    $build_cfg->{'numsections'} = $self->{'buildproc'}->get_num_sections();
    440432    $build_cfg->{'numbytes'} = $self->{'buildproc'}->get_num_bytes();
    441 
    442     # store whether to disable OAI service
    443     $build_cfg->{'disable_OAI'} = $self->{'disable_OAI'};
    444        
     433   
    445434    # store the mapping between the index names and the directory names
    446435    # the index map is used to determine what indexes there are, so any that are not built should not be put into the map.
     
    478467
    479468    if ($gs_mode eq "gs2") {
    480       #&colcfg::write_build_cfg_xml("$self->{'build_dir'}/buildConfig.xml", $build_cfg, $self->{'collect_cfg'});
    481469      &colcfg::write_build_cfg("$self->{'build_dir'}/build.cfg", $build_cfg);
    482470    }
    483471    if ($gs_mode eq "gs3") {
    484       #&colcfg::write_build_cfg("$self->{'build_dir'}/build.cfg", $build_cfg);
    485       &colcfg::write_build_cfg_xml("$self->{'build_dir'}/buildConfig.xml", $build_cfg, $self->{'collect_cfg'});
     472      &colcfg::write_build_cfg_xml("$self->{'build_dir'}/buildConfig.xml", $build_cfg, $self->{'collect_cfg'}, $self->{'disable_OAI'});
    486473    }   
    487474
Note: See TracChangeset for help on using the changeset viewer.