Changeset 12399


Ignore:
Timestamp:
2006-08-04T10:47:22+12:00 (18 years ago)
Author:
kjdon
Message:

I rearranged some stuff so that all the essential checks are done first. Also added in a check for missing import directory

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/bin/script/import.pl

    r12370 r12399  
    294294    die "\n";
    295295    }
     296
    296297    # add collection's perllib dir  into include path in
    297298    # case we have collection specific modules
    298299    unshift (@INC, "$ENV{'GSDLCOLLECTDIR'}/perllib");
    299300
     301    # check that we can open the faillog
    300302    if ($faillog eq "") {
    301303    $faillog = &util::filename_cat($ENV{'GSDLCOLLECTDIR'}, "etc", "fail.log");
     
    308310    $faillog = 'import::FAILLOG';
    309311    $faillog->autoflush(1);
    310 
    311     # check sortmeta
    312     $sortmeta = undef unless defined $sortmeta && $sortmeta =~ /\S/;
    313     if (defined $sortmeta && $groupsize > 1) {
    314     &gsprintf($out, "{import.cannot_sort}\n\n");
    315     $sortmeta = undef;
    316     }
    317 
    318     # get the list of plugins for this collection and set any options that
    319     # were specified in the collect.cfg (all import.pl options except
    320     # -collectdir, -out and -faillog may be specified in the collect.cfg (these
    321     # options must be known before we read the collect.cfg))
    322     my $plugins = [];
    323     my @global_opts = ();
    324    
     312   
     313    # check that there is a collect.cfg file
    325314    $configfilename = &util::filename_cat ($ENV{'GSDLCOLLECTDIR'}, "etc", "collect.cfg");
    326315    if (!-e $configfilename) {
    327316    (&gsprintf($out, "{common.cannot_find_cfg_file}\n", $configfilename) && die);
    328317    }
    329    
    330318    $collectcfg = &colcfg::read_collect_cfg ($configfilename);
     319
     320   
     321    if (defined $collectcfg->{'importdir'} && $importdir eq "") {
     322    $importdir = $collectcfg->{'importdir'};
     323    }
     324    if (defined $collectcfg->{'archivedir'} && $archivedir eq "") {
     325    $archivedir = $collectcfg->{'archivedir'};
     326    }
     327    # fill in the default import and archives directories if none
     328    # were supplied, turn all \ into / and remove trailing /
     329    $importdir = &util::filename_cat ($ENV{'GSDLCOLLECTDIR'}, "import") if $importdir eq "";
     330    $importdir =~ s/[\\\/]+/\//g;
     331    $importdir =~ s/\/$//;
     332    if (!-e $importdir) {
     333    &gsprintf($out, "{import.no_import_dir}\n\n", $importdir);
     334    die "\n";
     335    }
     336
     337    $archivedir = &util::filename_cat ($ENV{'GSDLCOLLECTDIR'}, "archives") if $archivedir eq "";
     338    $archivedir =~ s/[\\\/]+/\//g;
     339    $archivedir =~ s/\/$//;
     340
     341    my $plugins = [];
    331342    if (defined $collectcfg->{'plugin'}) {
    332343    $plugins = $collectcfg->{'plugin'};
    333344    }
     345    #some global options for the plugins
     346    my @global_opts = ();
    334347
    335348    if ($verbosity !~ /\d+/) {
     
    340353    }
    341354    }
    342     if (defined $collectcfg->{'importdir'} && $importdir eq "") {
    343     $importdir = $collectcfg->{'importdir'};
    344     }
    345     if (defined $collectcfg->{'archivedir'} && $archivedir eq "") {
    346     $archivedir = $collectcfg->{'archivedir'};
    347     }
    348355    if (defined $collectcfg->{'manifest'} && $manifest eq "") {
    349356    $manifest = $collectcfg->{'manifest'};
     
    355362    }
    356363    }
     364
    357365    if ($maxdocs !~ /\-?\d+/) {
    358366    if (defined $collectcfg->{'maxdocs'} && $collectcfg->{'maxdocs'} =~ /\-?\d+/) {
     
    387395    $sortmeta = $collectcfg->{'sortmeta'};
    388396    }
    389    
     397    # sortmeta cannot be used with group size
     398    $sortmeta = undef unless defined $sortmeta && $sortmeta =~ /\S/;
     399    if (defined $sortmeta && $groupsize > 1) {
     400    &gsprintf($out, "{import.cannot_sort}\n\n");
     401    $sortmeta = undef;
     402    }
     403
    390404    if (defined $collectcfg->{'removeprefix'} && $removeprefix eq "") {
    391405    $removeprefix = $collectcfg->{'removeprefix'};
     
    415429    print STDERR "<Import>\n" if $gli;
    416430   
    417     # fill in the default import and archives directories if none
    418     # were supplied, turn all \ into / and remove trailing /
    419     $importdir = &util::filename_cat ($ENV{'GSDLCOLLECTDIR'}, "import") if $importdir eq "";
    420     $importdir =~ s/[\\\/]+/\//g;
    421     $importdir =~ s/\/$//;
    422     $archivedir = &util::filename_cat ($ENV{'GSDLCOLLECTDIR'}, "archives") if $archivedir eq "";
    423     $archivedir =~ s/[\\\/]+/\//g;
    424     $archivedir =~ s/\/$//;
    425 
    426431    my $manifest_lookup = new manifest();
    427432    if ($manifest ne "") { 
     
    470475
    471476
    472          ####Use Plugout####
    473          my ($plugout_name);
     477    ####Use Plugout####
     478    my ($plugout_name);
    474479        if ($saveas !~ /^(GA|METS)Plugout$/  ){     
    475480        $plugout_name = $saveas."Plugout";
     
    477482        else{
    478483            $plugout_name = $saveas;
    479           }
    480 
    481          my $opts=[];
    482 
     484    }
     485   
     486    my $opts=[];
     487   
    483488    push @$opts,("-output_info",$archive_info) if (defined $archive_info);
    484489   
Note: See TracChangeset for help on using the changeset viewer.