Changeset 6976


Ignore:
Timestamp:
2004-03-09T14:14:56+13:00 (20 years ago)
Author:
kjdon
Message:

removed Johns construction error stuff so that it dies during new if metadata and hfile args are not valid

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/perllib/classify/Hierarchy.pm

    r6968 r6976  
    2626# classifier plugin for generating hierarchical classifications
    2727
    28 # 12/05/02 Added usage datastructure - John Thompson
    29 # 12/05/02 Modified new() so as not to die on error, only on init() - John Thompson
    3028
    3129package Hierarchy;
     
    9593             "allow_extra_options")) {
    9694   
    97     $self->{'construction_error'} = "Incorrect options passed to $class, check your collect.cfg file.";
     95    print STDERR "\nIncorrect options passed to $class, check your collect.cfg file\n";
     96    $self->print_txt_usage("");  # Use default resource bundle
     97    die "\n";
     98
    9899    }
    99100
    100101    if (!$metadata) {
    101     $self->{'construction_error'} = "Hierarchy error: no metadata supplied.";
     102    print STDERR "$class: -metadata option REQUIRED \n";
     103    $self->print_txt_usage("");  # Use default resource bundle
     104   
     105    die "$class: -metadata option REQUIRED\n";
     106    }
     107   
     108    if (!$hfile) {
     109    print STDERR "$class: -hfile option REQUIRED \n";
     110    $self->print_txt_usage("");  # Use default resource bundle
     111   
     112    die "$class: -hfile option REQUIRED\n";
    102113    }
    103114   
     
    106117    $sortname = $metadata unless ($sortname);
    107118    $sortname = undef if $sortname =~ /^nosort$/;
     119   
    108120    my $subjectfile;
    109 
    110     if (!$hfile) {
    111     $self->{'construction_error'} = "Hierarchy error: No -hfile supplied.";
    112     }
    113     else
    114     {
    115     $subjectfile = &util::filename_cat($ENV{'GSDLCOLLECTDIR'},"etc", $hfile);
     121    $subjectfile = &util::filename_cat($ENV{'GSDLCOLLECTDIR'},"etc", $hfile);
     122    if (!-e $subjectfile) {
     123    my $collfile = $subjectfile;
     124    $subjectfile = &util::filename_cat($ENV{'GSDLHOME'},"etc", $hfile);
    116125    if (!-e $subjectfile) {
    117         my $collfile = $subjectfile;
    118         $subjectfile = &util::filename_cat($ENV{'GSDLHOME'},"etc", $hfile);
    119         if (!-e $subjectfile) {
    120         my $outhandle = $self->{'outhandle'};
    121         $self->print_txt_usage("");  # Use default resource bundle
    122         print STDERR "\nHierarchy Error: Can't locate subject file $hfile\n";
    123         print STDERR "This file should be in $collfile or $subjectfile\n";
    124         die "\n";
    125         }
     126        my $outhandle = $self->{'outhandle'};
     127        print STDERR "\nHierarchy Error: Can't locate subject file $hfile\n";
     128        print STDERR "This file should be in $collfile or $subjectfile\n";
     129        $self->print_txt_usage("");  # Use default resource bundle
     130        print STDERR "\nHierarchy Error: Can't locate subject file $hfile\n";
     131        print STDERR "This file should be in $collfile or $subjectfile\n";
     132        die "\n";
    126133    }
    127134    }
     
    140147sub init {
    141148    my $self = shift (@_);
    142    
    143     if(defined $self->{'construction_error'} || !defined $self->{'metaname'} || !defined $self->{'subjectfile'}) {
    144     print STDERR "Error: " , $self->{'construction_error'} , "\n";
    145     $self->print_txt_usage("");  # Use default resource bundle
    146     die "\n";
    147     }
    148149   
    149150    # read in the subject file
Note: See TracChangeset for help on using the changeset viewer.