Changeset 14112 for trunk


Ignore:
Timestamp:
2007-05-30T17:55:36+12:00 (17 years ago)
Author:
sjboddie
Message:

More modifications to support additional collection-level customisations
to be put in gsdl/collect/COLLECTION/custom/COLLECTION. basebuilder.pm,
classify.pm, colcfg.pm, and plugin.pm were modified to allow
collection-specific plugins, classifiers, builders, and buildprocs to
be located in the new locations. These changes should not have any effect
on existing collections.

Location:
trunk/gsdl/perllib
Files:
4 edited

Legend:

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

    r14022 r14112  
    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) = @_;
    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    $self->{'gli'} = 0 unless defined $self->{'gli'};
    8184
    82     # read in the collection configuration file
    83     my $colcfgname = "$ENV{'GSDLCOLLECTDIR'}/etc/collect.cfg";
    84     if (-e $colcfgname) {
    85       $self->{'collect_cfg'} = &colcfg::read_collect_cfg ($colcfgname);
    86       $gs_mode = "gs2";
    87     }
    88     else {
    89       my $colcfgname = "$ENV{'GSDLCOLLECTDIR'}/etc/collectionConfig.xml";
    90       if (!-e $colcfgname) {
    91     die "mgbuilder::new - couldn't find collect.cfg for collection $collection\n";
    92       }
    93       else {
     85    # Read in the collection configuration file.
     86    my ($colcfgname);
     87    ($colcfgname, $gs_mode) = &colcfg::get_collect_cfg_name($outhandle);
     88    if ($gs_mode eq "gs2") {
     89        $self->{'collect_cfg'} = &colcfg::read_collect_cfg ($colcfgname);
     90    } elsif ($gs_mode eq "gs3") {
    9491    $self->{'collect_cfg'} = &colcfg::read_collection_cfg_xml ($colcfgname);
    95     $gs_mode = "gs3";
    96       }
    9792    }
    9893   
     
    192187    my ($buildprocdir, $buildproctype);
    193188    my $collection = $self->{'collection'};
    194     if (-e "$ENV{'GSDLCOLLECTDIR'}/perllib/${collection}buildproc.pm") {
     189    if (-e "$ENV{'GSDLCOLLECTDIR'}/custom/${collection}/perllib/custombuildproc.pm") {
     190    $buildprocdir = "$ENV{'GSDLCOLLECTDIR'}/custom/${collection}/perllib";
     191    $buildproctype = "custombuildproc";
     192    } elsif (-e "$ENV{'GSDLCOLLECTDIR'}/perllib/custombuildproc.pm") {
     193    $buildprocdir = "$ENV{'GSDLCOLLECTDIR'}/perllib";
     194    $buildproctype = "custombuildproc";
     195    } elsif (-e "$ENV{'GSDLCOLLECTDIR'}/perllib/${collection}buildproc.pm") {
    195196    $buildprocdir = "$ENV{'GSDLCOLLECTDIR'}/perllib";
    196197    $buildproctype = "${collection}buildproc";
     
    338339    my ($handle);
    339340    if ($self->{'debug'}) {
    340     $handle = STDOUT;
     341    $handle = *STDOUT;
    341342    } else {
    342343    if (!-e "$txt2db_exe" || !open (PIPEOUT, "| txt2db$exe \"$fulldbname\"")) {
     
    344345        die "builder::make_infodatabase - couldn't run $txt2db_exe\n";
    345346    }
    346     $handle = basebuilder::PIPEOUT;
     347    $handle = *PIPEOUT;
    347348    }
    348349   
  • trunk/gsdl/perllib/classify.pm

    r13933 r14112  
    4949
    5050    # find the classifier
    51     my $colclassname = &util::filename_cat($ENV{'GSDLCOLLECTDIR'},
    52                        "perllib/classify",
    53                        "${classifier}.pm");
    54     my $mainclassname = &util::filename_cat($ENV{'GSDLHOME'},
    55                         "perllib/classify",
    56                         "${classifier}.pm");
    57 
    58     if (-e $colclassname) { require $colclassname; }
     51    my $customclassname = &util::filename_cat($ENV{'GSDLCOLLECTDIR'}, "custom", $ENV{'GSDLCOLLECTION'},
     52                                              "perllib", "classify", "${classifier}.pm");
     53    my $colclassname = &util::filename_cat($ENV{'GSDLCOLLECTDIR'}, "perllib", "classify", "${classifier}.pm");
     54    my $mainclassname = &util::filename_cat($ENV{'GSDLHOME'}, "perllib", "classify", "${classifier}.pm");
     55
     56    if (-e $customclassname) { require $customclassname; }
     57    elsif (-e $colclassname) { require $colclassname; }
    5958    elsif (-e $mainclassname) { require $mainclassname; }
    6059    else {
     
    8483
    8584    # find the classifier
    86     my $colclassname = &util::filename_cat($ENV{'GSDLCOLLECTDIR'},"perllib/classify",
    87                            "${classname}.pm");
    88     my $mainclassname = &util::filename_cat($ENV{'GSDLHOME'},"perllib/classify",
    89                         "${classname}.pm");
    90 
    91     if (-e $colclassname) { require $colclassname; }
     85        my $customclassname = &util::filename_cat($ENV{'GSDLCOLLECTDIR'}, "custom", $ENV{'GSDLCOLLECTION'},
     86                                                  "perllib", "classify", "${classname}.pm");
     87        my $colclassname = &util::filename_cat($ENV{'GSDLCOLLECTDIR'}, "perllib", "classify", "${classname}.pm");
     88        my $mainclassname = &util::filename_cat($ENV{'GSDLHOME'}, "perllib", "classify", "${classname}.pm");
     89
     90    if (-e $customclassname) { require $customclassname; }
     91    elsif (-e $colclassname) { require $colclassname; }
    9292    elsif (-e $mainclassname) { require $mainclassname; }
    9393    else { &gsprintf(STDERR, "{classify.could_not_find_classifier}\n", $classname) && die "\n";
    9494           # die "ERROR - couldn't find classifier \"$classname\"\n";
    95        }
     95        }
    9696
    9797    # create the classify object
  • trunk/gsdl/perllib/colcfg.pm

    r14023 r14112  
    3030use cfgread;
    3131use cfgread4gs3;
     32use gsprintf 'gsprintf';
    3233use strict;
    3334
     
    160161}
    161162
     163sub get_collect_cfg_name {
     164    my ($out) = @_;
     165
     166    # First check if there's a
     167    # gsdl/collect/COLLECTION/custom/COLLECTION/etc/collect.cfg file. This
     168    # customization was added for DLC by Stefan, 30/6/2007.
     169    my $configfilename = &util::filename_cat ($ENV{'GSDLCOLLECTDIR'}, "custom", $ENV{'GSDLCOLLECTION'}, "etc", "collect.cfg");
     170
     171    if (-e $configfilename) {
     172        return ($configfilename, "gs2");
     173    }
     174
     175    # Now check if there is a collect.cfg file in the usual place, i.e. it is gs2.
     176    $configfilename = &util::filename_cat ($ENV{'GSDLCOLLECTDIR'}, "etc", "collect.cfg");
     177    if (-e $configfilename) {
     178        return ($configfilename, "gs2");
     179    }
     180
     181    # If we get to here we check if there is a collectionConfig.xml file,
     182    # i.e. it is gs3.
     183    $configfilename = &util::filename_cat ($ENV{'GSDLCOLLECTDIR'}, "etc", "collectionConfig.xml");   
     184    if (-e $configfilename) {
     185        return ($configfilename, "gs3");
     186    }
     187
     188    # Error. No collection configuration file.
     189    (&gsprintf($out, "{common.cannot_find_cfg_file}\n", $configfilename) && die);
     190}
     191
    1621921;
    163193
  • trunk/gsdl/perllib/plugin.pm

    r13933 r14112  
    4848
    4949    # find the plugin
    50     my $colplugname = &util::filename_cat($ENV{'GSDLCOLLECTDIR'},"perllib/plugins",
     50    my $customplugname = &util::filename_cat($ENV{'GSDLCOLLECTDIR'}, "custom", $ENV{'GSDLCOLLECTION'},
     51                                             'perllib', 'plugins', "${pluginname}.pm");
     52    my $colplugname = &util::filename_cat($ENV{'GSDLCOLLECTDIR'}, 'perllib', 'plugins',
    5153                      "${pluginname}.pm");
    52     my $mainplugname = &util::filename_cat($ENV{'GSDLHOME'},"perllib/plugins",
     54    my $mainplugname = &util::filename_cat($ENV{'GSDLHOME'}, 'perllib', 'plugins',
    5355                       "${pluginname}.pm");
    54     if (-e $colplugname) { require $colplugname; }
     56    if (-e $customplugname) { require $customplugname; }
     57    elsif (-e $colplugname) { require $colplugname; }
    5558    elsif (-e $mainplugname) { require $mainplugname; }
    5659    else {
     
    9194
    9295    # find the plugin
    93     my $colplugname = &util::filename_cat($ENV{'GSDLCOLLECTDIR'},"perllib/plugins",
     96        my $customplugname = &util::filename_cat($ENV{'GSDLCOLLECTDIR'}, "custom", $ENV{'GSDLCOLLECTION'},
     97                                                 'perllib', 'plugins', "${pluginname}.pm");
     98    my $colplugname = &util::filename_cat($ENV{'GSDLCOLLECTDIR'}, 'perllib', 'plugins',
    9499                          "${pluginname}.pm");
    95     my $mainplugname = &util::filename_cat($ENV{'GSDLHOME'},"perllib/plugins",
     100    my $mainplugname = &util::filename_cat($ENV{'GSDLHOME'}, 'perllib', 'plugins',
    96101                           "${pluginname}.pm");
    97     if (-e $colplugname) { require $colplugname; }
     102        if (-e $customplugname) { require $customplugname; }
     103    elsif (-e $colplugname) { require $colplugname; }
    98104    elsif (-e $mainplugname) { require $mainplugname; }
    99105    else {
Note: See TracChangeset for help on using the changeset viewer.