Changeset 26567


Ignore:
Timestamp:
2012-12-10T16:37:21+13:00 (11 years ago)
Author:
ak19
Message:

When a GS2 collection contains both collect.cfg and collectionConfig.xml (as advanced beatles does) the old code used to end up reading in the GS3 collectionConfig.xml instead of the GS2 collect.cfg and set the GS_mode to GS3. Now colcfg::get_collect_cfg_name takes the gs_mode (instead of determining this and returning it) and works out the collectcfg file name for the gs_mode. That means that the calling functions now need to work out the gs_mode. They do so by setting the gs_mode to gs3 if the site flag is present in the commandline, if not then it defaults to gs2. So from now on, the site flag must be specified for GS3 collections.

Location:
main/trunk/greenstone2
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/bin/script/activate.pl

    r25896 r26567  
    488488    # Beware: Only if $site is specified in the cmdline does collectionConfig.xml get
    489489    # generated and does $gs_mode=gs3, else collect.cfg gets generated and $gs_mode=gs2
    490     my ($collect_cfg_filename, $gs_mode) = &colcfg::get_collect_cfg_name(STDERR);
     490    my $gs_mode = "gs2";
     491    if ((defined $site) && ($site ne "")) { # GS3
     492    $gs_mode = "gs3";
     493    }
     494    my $collect_cfg_filename = &colcfg::get_collect_cfg_name(STDERR, $gs_mode);
    491495    my $collectcfg = &colcfg::read_collection_cfg ($collect_cfg_filename,$gs_mode);
    492496
  • main/trunk/greenstone2/bin/script/buildcol.pl

    r25896 r26567  
    386386    # Read in the collection configuration file.
    387387    my ($collectcfg, $buildtype, $orthogonalbuildtypes);
    388     ($configfilename, $gs_mode) = &colcfg::get_collect_cfg_name($out);
     388    if ((defined $site) && ($site ne "")) { # GS3
     389    $gs_mode = "gs3";
     390    }
     391    $configfilename = &colcfg::get_collect_cfg_name($out, $gs_mode);
    389392    $collectcfg = &colcfg::read_collection_cfg ($configfilename, $gs_mode);
    390393   
  • main/trunk/greenstone2/bin/script/explode_metadata_database.pl

    r24952 r26567  
    229229    # read in the collect.cfg file
    230230    # Read in the collection configuration file.
    231     my ($configfilename, $gs_mode) = &colcfg::get_collect_cfg_name(STDERR);
     231    my $gs_mode = "gs2";
     232    if ((defined $site) && ($site ne "")) { # GS3
     233        $gs_mode = "gs3";
     234    }
     235    my $configfilename = &colcfg::get_collect_cfg_name(STDERR, $gs_mode);
    232236    my $collectcfg = &colcfg::read_collect_cfg ($configfilename, $gs_mode);
    233237    $plugin_options_string = &get_plugin_options($collectcfg, $plugin);
  • main/trunk/greenstone2/bin/script/incremental-buildcol.pl

    r24749 r26567  
    104104
    105105    # Read in the collection configuration file.
    106     my ($collect_cfg_filename, $gs_mode) = &colcfg::get_collect_cfg_name(STDERR);
     106    my $gs_mode = "gs2";
     107    if ((defined $site) && ($site ne "")) { # GS3
     108    $gs_mode = "gs3";
     109    }
     110    my $collect_cfg_filename = &colcfg::get_collect_cfg_name(STDERR, $gs_mode);
    107111   
    108112    my $collectcfg = &colcfg::read_collection_cfg ($collect_cfg_filename,$gs_mode);
  • main/trunk/greenstone2/perllib/basebuilder.pm

    r26094 r26567  
    8686   
    8787    # Read in the collection configuration file.
    88     my ($colcfgname);
    89     ($colcfgname, $gs_mode) = &colcfg::get_collect_cfg_name($outhandle);
     88    if ((defined $site) && ($site ne "")) { # GS3
     89    $gs_mode = "gs3";
     90    }
     91
     92    my $colcfgname = &colcfg::get_collect_cfg_name($outhandle, $gs_mode);
    9093    $self->{'collect_cfg'} = &colcfg::read_collection_cfg ($colcfgname, $gs_mode);
    9194
  • main/trunk/greenstone2/perllib/cgiactions/explodeaction.pm

    r24071 r26567  
    9191
    9292    # Read in the collection configuration file.
    93     my ($config_filename, $gs_mode) = &colcfg::get_collect_cfg_name($out);
     93    my $gs_mode = "gs2";
     94    if ((defined $site) && ($site ne "")) { # GS3
     95    $gs_mode = "gs3";
     96    }
     97    my $config_filename = &colcfg::get_collect_cfg_name($out, $gs_mode);
    9498    my $collectcfg = &colcfg::read_collection_cfg ($config_filename, $gs_mode);
    9599
  • main/trunk/greenstone2/perllib/colcfg.pm

    r25677 r26567  
    261261
    262262# method to check for filename of collect.cfg, and gs mode.
    263 sub get_collect_cfg_name {
     263sub get_collect_cfg_name_old {
    264264    my ($out) = @_;
    265265
     
    288288    (&gsprintf($out, "{common.cannot_find_cfg_file}\n", $configfilename) && die);
    289289}
     290
     291# method to check for filename of collect.cfg
     292# needs to be given gs_version, since we can have a GS2 collection ported into
     293# GS3 which could potentially have collect.cfg AND collectionConfig.xml
     294# in which case the older version of this subroutine (get_collect_cfg_name_old)
     295# will return the wrong answer for the gs version we're using.
     296sub get_collect_cfg_name {
     297    my ($out, $gs_version) = @_;
     298
     299    # First check if there's a
     300    # gsdl/collect/COLLECTION/custom/COLLECTION/etc/custom.cfg file. This
     301    # customization was added for DLC by Stefan, 30/6/2007.
     302    my $configfilename;
     303
     304    if($gs_version eq "gs2") {
     305    $configfilename = &util::filename_cat ($ENV{'GSDLCOLLECTDIR'}, "custom", $ENV{'GSDLCOLLECTION'}, "etc", "custom.cfg");
     306   
     307    if (-e $configfilename) {
     308        return $configfilename;
     309    }
     310    }
     311
     312    # Check if there is a collectionConfig.xml file if it's gs3
     313    if($gs_version eq "gs3") {
     314    $configfilename = &util::filename_cat ($ENV{'GSDLCOLLECTDIR'}, "etc", "collectionConfig.xml");   
     315    if (-e $configfilename) {
     316        return $configfilename;
     317    }
     318    }
     319
     320    # Check if there is a collect.cfg file in the usual place for gs2.
     321    if($gs_version eq "gs2") {
     322    $configfilename = &util::filename_cat ($ENV{'GSDLCOLLECTDIR'}, "etc", "collect.cfg");
     323    if (-e $configfilename) {
     324        return $configfilename;
     325    }
     326    }
     327
     328    # Error. No collection configuration file.
     329    (&gsprintf($out, "{common.cannot_find_cfg_file}\n", $configfilename) && die);
     330}
     331
    290332
    291333
  • main/trunk/greenstone2/perllib/inexport.pm

    r26536 r26567  
    173173    }
    174174
    175     # set gs_verison 2/3
     175    # set gs_version 2/3
    176176    $self->{'gs_version'} = "2";
    177177    if ((defined $site) && ($site ne "")) {
     
    199199
    200200    # Read in the collection configuration file.
    201     my ($config_filename, $gs_mode) = &colcfg::get_collect_cfg_name($out);
     201    my $gs_mode = "gs".$self->{'gs_version'}; #gs2 or gs3
     202    my $config_filename = &colcfg::get_collect_cfg_name($out, $gs_mode);
    202203    my $collectcfg = &colcfg::read_collection_cfg ($config_filename, $gs_mode);
    203204
Note: See TracChangeset for help on using the changeset viewer.