Changeset 32511


Ignore:
Timestamp:
2018-10-10T21:25:13+13:00 (4 years ago)
Author:
ak19
Message:

Running plugoutinfo.pl with describeall or listall flag would break on FedoraMETSPlugout when either FEDORA_HOME or FEDORA_VERSION aren't set (as is often the case), as there's a die statement in the BEGIN of FedoraMETSPlugout. Needed to run die if either FEDORA env var is not set only if the plugout is NOT in info_only mode in plugout constructor. However, info_only mode was never set in any of the plugouts, so had to add set up the infrastructure for it in plugoutinfo.pl and plugout.pm. Then added the info_only test to all teh plugouts, even though it's redundant in most of them for making sure future changes to any plugout's constructors does not break plugoutinfo.pl.

Location:
main/trunk/greenstone2
Files:
9 edited

Legend:

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

    r17201 r32511  
    177177        my $plugout;
    178178        push @$plugout,$plugout_name;
    179         my $plugoutobj = &plugout::load_plugout ($plugout);
     179        my $plugoutobj = &plugout::load_plugout ($plugout, "info_only");
    180180        if ($describeall) {
    181181        $plugoutobj->print_xml_usage(0);
     
    202202    push @$plugout,$plugout_name;
    203203
    204     my $plugoutobj = &plugout::load_plugout($plugout);
     204    my $plugoutobj = &plugout::load_plugout($plugout, "info_only");
    205205
    206206    if ($xml) {
  • main/trunk/greenstone2/perllib/plugout.pm

    r27306 r32511  
    4848sub load_plugout{
    4949    my ($plugout) = shift @_;
     50    my ($info_only) = shift @_; # optional. Set to info_only if we're just printing out plugout info
    5051    my $plugout_name = shift @$plugout;
     52
    5153    my $plugout_suffix = &FileUtils::filenameConcatenate('perllib', 'plugouts', $plugout_name . '.pm');
    5254    my $plugout_found = 0;
     
    148150    my ($plugobj);
    149151
     152    # if just doing plugoutinfo.pl, add in -gsdlinfo to plugout object's options
     153    if($info_only) {
     154    unshift (@$plugout, "-gsdlinfo");
     155    }
     156   
    150157    eval ("\$plugobj = new \$plugout_name([],\$plugout)");
    151158    die "$@" if $@;
  • main/trunk/greenstone2/perllib/plugouts/BasePlugout.pm

    r32159 r32511  
    133133
    134134    # Check if gsdlinfo is in the argument list or not - if it is, don't parse
    135     # the args, just return the object. 
     135    # the args, just return the object.
     136    #print STDERR "#### " . join(",", @${args}) . "\n\n";
    136137    foreach my $strArg (@{$args})
    137138    {
  • main/trunk/greenstone2/perllib/plugouts/DSpacePlugout.pm

    r27882 r32511  
    6060    push(@{$hashArgOptLists->{"OptList"}},$options);
    6161
    62     my $self = new BasePlugout($plugoutlist,$inputargs,$hashArgOptLists);   
    63 
     62    my $self = new BasePlugout($plugoutlist,$inputargs,$hashArgOptLists);
     63   
     64    if ($self->{'info_only'}) {
     65        # don't worry about any options etc
     66        return bless $self, $class;
     67    }
    6468#    print STDERR "***** metadata prefix = \"", $self->{'metadata_prefix'}, "\"\n";
    6569
  • main/trunk/greenstone2/perllib/plugouts/FedoraMETSPlugout.pm

    r28562 r32511  
    3737    @FedoraMETSPlugout::ISA = ('METSPlugout');
    3838
    39     if ((!defined $ENV{'FEDORA_HOME'}) || (!defined $ENV{'FEDORA_VERSION'})) {
    40     if (defined $ENV{'FEDORA_HOME'}) {
    41         print STDERR "FEDORA_HOME = $ENV{'FEDORA_HOME'}";
    42     }
    43 
    44     if (defined $ENV{'FEDORA_VERSION'}) {
    45         print STDERR "FEDORA_VERSION = $ENV{'FEDORA_VERSION'}";
    46     }
    47 
    48     die "Need both environment variables FEDORA_HOME and FEDORA_VERSION to be set\n";
    49     }
     39    # Need both environment variables FEDORA_HOME and FEDORA_VERSION to be set to use this plugout!
     40    # But we only test these vars are set in the constructor, so as not to break plugoutinfo.pl by
     41    # a 'die' statement here nor break the xml that plugoutinfo.pl produces with print stmts here
     42
    5043
    5144    $ENV{'FEDORA_HOSTNAME'} = "localhost" if (!defined $ENV{'FEDORA_HOSTNAME'});
     
    8881   
    8982    my $self = new METSPlugout($plugoutlist,$inputargs,$hashArgOptLists);
    90 
     83   
     84    if ($self->{'info_only'}) {
     85        # don't worry about any options etc
     86        return bless $self, $class;
     87    }
     88   
     89    # else (if we're not producing information for plugoutinfo.pl) make sure
     90    # BOTH env vars FEDORA_HOME and FEDORA_VERSION are set. If either not set, die.
     91    if ((!defined $ENV{'FEDORA_HOME'}) || (!defined $ENV{'FEDORA_VERSION'})) {
     92    if (defined $ENV{'FEDORA_HOME'}) {
     93        print STDERR "FEDORA_HOME = $ENV{'FEDORA_HOME'}";
     94    }
     95   
     96    if (defined $ENV{'FEDORA_VERSION'}) {
     97        print STDERR "FEDORA_VERSION = $ENV{'FEDORA_VERSION'}";
     98    }
     99   
     100    die "ERROR: Need both environment variables FEDORA_HOME and FEDORA_VERSION to be set\n";
     101    }
     102   
    91103    return bless $self, $class;
    92104}
  • main/trunk/greenstone2/perllib/plugouts/GreenstoneMETSPlugout.pm

    r17203 r32511  
    5757
    5858    my $self = new METSPlugout($plugoutlist,$inputargs,$hashArgOptLists);
     59   
     60    if ($self->{'info_only'}) {
     61        # don't worry about any options etc
     62        return bless $self, $class;
     63    }
    5964   
    6065    return bless $self, $class;
  • main/trunk/greenstone2/perllib/plugouts/GreenstoneXMLPlugout.pm

    r28642 r32511  
    6363
    6464    my $self = new BasePlugout($plugoutlist,$inputargs,$hashArgOptLists);
    65  
     65   
     66    if ($self->{'info_only'}) {
     67        # don't worry about any options etc
     68        return bless $self, $class;
     69    }
    6670    return bless $self, $class;
    6771}
  • main/trunk/greenstone2/perllib/plugouts/MARCXMLPlugout.pm

    r28706 r32511  
    7878
    7979    my $self = new BasePlugout($plugoutlist,$inputargs,$hashArgOptLists);
    80 
     80   
     81    if ($self->{'info_only'}) {
     82        # don't worry about any options etc
     83        return bless $self, $class;
     84    }
     85   
    8186    $self->{'buffered_output'} ="";
    8287     
  • main/trunk/greenstone2/perllib/plugouts/METSPlugout.pm

    r28708 r32511  
    7171
    7272    my $self = new BasePlugout($plugoutlist,$inputargs,$hashArgOptLists);
    73 
     73   
     74    if ($self->{'info_only'}) {
     75        # don't worry about any options etc
     76        return bless $self, $class;
     77    }
     78   
    7479    if(defined $self->{'xslt_txt'} &&  $self->{'xslt_txt'} ne "")
    7580    {
Note: See TracChangeset for help on using the changeset viewer.