Changeset 28705
- Timestamp:
- 2013-11-28T15:00:56+13:00 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone2/perllib/inexport.pm
r28641 r28705 70 70 'type' => "string", 71 71 'reqd' => "no", 72 'deft' => "import", 72 73 'hiddengli' => "yes" }, 73 74 { 'name' => "collectdir", … … 89 90 'type' => "enum", 90 91 'list' => $oidtype_list, 91 # parsearg left "" as default 92 #'deft' => "hash", 92 'deft' => "hash_on_full_filename", 93 93 'reqd' => "no", 94 94 'modegli' => "2" }, … … 96 96 'desc' => "{import.OIDmetadata}", 97 97 'type' => "string", 98 #'type' => "metadata", #doesn't work properly in GLI 99 # parsearg left "" as default 100 #'deft' => "dc.Identifier", 98 'deft' => "dc.Identifier", 101 99 'reqd' => "no", 102 100 'modegli' => "2" }, … … 136 134 'type' => "int", 137 135 'reqd' => "no", 138 # parsearg left "" as default 139 #'deft' => "-1", 140 'range' => "1,", 136 'deft' => "-1", 137 'range' => "-1,", 141 138 'modegli' => "1" }, 142 139 { 'name' => "debug", … … 169 166 'type' => "int", 170 167 'range' => "0,", 171 # parsearg left "" as default 172 # 'deft' => "2", 168 'deft' => "2", 173 169 'reqd' => "no", 174 170 'modegli' => "3" }, … … 239 235 if ($intArgLeftinAfterParsing != 1 || (@$argv && $argv->[0] =~ /^\-+h/)) 240 236 { 241 ## TODO if we had invalid arg, can we sign lathat to user???237 ## TODO if we had invalid arg, can we signal that to user??? 242 238 &PrintUsage::print_txt_usage($options, "{import.params}"); 243 239 die "\n"; … … 356 352 my $inexport_mode = $self->{'mode'}; 357 353 358 my $verbosity = $self->{'verbosity'};359 my $debug = $self->{'debug'};360 354 my $importdir = $self->{'importdir'}; 361 my $archivedir = $self->{'archivedir'} || $self->{'exportdir'} || "";355 my $archivedir = $self->{'archivedir'} || $self->{'exportdir'}; 362 356 my $out = $self->{'out'}; 363 357 … … 372 366 } 373 367 374 if (defined $ collectcfg->{'importdir'} && $importdir eq "") {368 if (defined $self->{'default_importdir'} && defined $collectcfg->{'importdir'}) { 375 369 $importdir = $collectcfg->{'importdir'}; 376 370 } 377 if (defined $collectcfg->{'archivedir'} && $archivedir eq "") { 378 $archivedir = $collectcfg->{'archivedir'}; 371 372 if ($inexport_mode eq "import") { 373 if ( defined $self->{'default_archivedir'} && defined $collectcfg->{'archivedir'}) { 374 $archivedir = $collectcfg->{'archivedir'}; 375 } 376 } 377 elsif ($inexport_mode eq "export") { 378 if (defined $self->{'default_exportdir'} && defined $collectcfg->{'exportdir'}) { 379 $archivedir = $collectcfg->{'exportdir'}; 380 } 379 381 } 380 382 # fill in the default import and archives directories if none 381 383 # were supplied, turn all \ into / and remove trailing / 382 if ( $importdir eq "")384 if (!&FileUtils::isFilenameAbsolute($importdir)) 383 385 { 384 $importdir = &FileUtils::filenameConcatenate($ENV{'GSDLCOLLECTDIR'}, "import");386 $importdir = &FileUtils::filenameConcatenate($ENV{'GSDLCOLLECTDIR'}, $importdir); 385 387 } 386 388 else … … 399 401 $self->{'importdir'} = $importdir; 400 402 401 if ($archivedir eq "") { 402 if ($inexport_mode eq "import") { 403 $archivedir = &FileUtils::filenameConcatenate($ENV{'GSDLCOLLECTDIR'}, "archives"); 404 } 405 elsif ($inexport_mode eq "export") { 406 $archivedir = &FileUtils::filenameConcatenate($ENV{'GSDLCOLLECTDIR'}, "export"); 407 } 408 else { 409 print STDERR "Warning: Unrecognized import/export mode '$inexport_mode'\n"; 410 print STDERR " Defaulting to 'archives' for file output\n"; 411 $archivedir = &FileUtils::filenameConcatenate($ENV{'GSDLCOLLECTDIR'}, "archives"); 412 } 413 } 414 415 $archivedir = &FileUtils::sanitizePath($archivedir); 416 #$archivedir =~ s/[\\\/]+/\//g; 417 #$archivedir =~ s/\/$//; 403 if (!&FileUtils::isFilenameAbsolute($archivedir)) { 404 $archivedir = &FileUtils::filenameConcatenate($ENV{'GSDLCOLLECTDIR'}, $archivedir); 405 } 406 else { 407 408 $archivedir = &FileUtils::sanitizePath($archivedir); 409 } 418 410 $self->{'archivedir'} = $archivedir; 419 411 420 if ( $verbosity !~ /\d+/) {412 if (defined $self->{'default_verbosity'}) { 421 413 if (defined $collectcfg->{'verbosity'} && $collectcfg->{'verbosity'} =~ /\d+/) { 422 $verbosity = $collectcfg->{'verbosity'}; 423 } else { 424 $verbosity = 2; # the default 425 } 426 } 427 $self->{'verbosity'} = $verbosity; 428 414 $self->{'verbosity'} = $collectcfg->{'verbosity'}; 415 } 416 } 417 429 418 if (defined $collectcfg->{'manifest'} && $self->{'manifest'} eq "") { 430 419 $self->{'manifest'} = $collectcfg->{'manifest'}; … … 437 426 } 438 427 439 if ( $self->{'maxdocs'} !~ /\-?\d+/) {428 if (defined $self->{'default_maxdocs'}) { 440 429 if (defined $collectcfg->{'maxdocs'} && $collectcfg->{'maxdocs'} =~ /\-?\d+/) { 441 430 $self->{'maxdocs'} = $collectcfg->{'maxdocs'}; 442 } else {443 $self->{'maxdocs'} = -1; # the default444 431 } 445 432 } … … 447 434 448 435 449 if (!defined $self->{'OIDtype'} 450 || ($self->{'OIDtype'} !~ /^(hash|hash_on_full_filename|incremental|assigned|filename|dirname|full_filename)$/ )) { 451 # OIDtype was either not defined on the command-line, or if it was not one of the recognized values 436 if (defined $self->{'default_OIDtype'} ) { 452 437 if (defined $collectcfg->{'OIDtype'} 453 438 && $collectcfg->{'OIDtype'} =~ /^(hash|hash_on_full_filename|incremental|assigned|filename|dirname|full_filename)$/) { 454 439 $self->{'OIDtype'} = $collectcfg->{'OIDtype'}; 455 } else { 456 $self->{'OIDtype'} = "hash"; # the default 457 } 458 } 459 460 if ((!defined $self->{'OIDmetadata'}) || ($self->{'OIDmetadata'} eq "")) { 440 } 441 } 442 443 if (defined $self->{'default_OIDmetadata'}) { 461 444 if (defined $collectcfg->{'OIDmetadata'}) { 462 445 $self->{'OIDmetadata'} = $collectcfg->{'OIDmetadata'}; 463 } else { 464 $self->{'OIDmetadata'} = "dc.Identifier"; # the default 465 } 446 } 466 447 } 467 448 … … 638 619 my $plugout; 639 620 621 my $generate_auxiliary_files = 0; 622 if ($inexport_mode eq "import") { 623 $generate_auxiliary_files = 1; 624 } 625 elsif ($self->{'include_auxiliary_database_files'}) { 626 $generate_auxiliary_files = 1; 627 } 628 $self->{'generate_auxiliary_files'} = $generate_auxiliary_files; 629 630 # Option to use user defined plugout 640 631 if ($inexport_mode eq "import") { 641 632 if (defined $collectcfg->{'plugout'}) { 642 633 # If a plugout was specified in the collect.cfg file, assume it is sensible 643 634 # We can't check the name because it could be anything, if it is a custom plugout 635 print STDERR "Using plugout specified in collect.cfg: $collectcfg->{'plugout'}\n"; 644 636 $plugout = $collectcfg->{'plugout'}; 645 637 } 646 else{ 647 if ($saveas !~ /^(GreenstoneXML|GreenstoneMETS)$/) { 648 push @$plugout,"GreenstoneXMLPlugout"; 649 } 650 else{ 651 push @$plugout,$saveas."Plugout"; 652 } 638 else { 639 push @$plugout,$saveas."Plugout"; 653 640 } 654 641 655 642 } 656 643 else { 657 if (defined $collectcfg->{'plugout'} && $collectcfg->{'plugout'} =~ /^( .*METS|DSpace|MARCXML)Plugout/) {644 if (defined $collectcfg->{'plugout'} && $collectcfg->{'plugout'} =~ /^(GreenstoneXML|.*METS|DSpace|MARCXML)Plugout/) { 658 645 $plugout = $collectcfg->{'plugout'}; 659 } 660 else{ 661 if ($saveas !~ /^(GreenstoneMETS|FedoraMETS|DSpace|MARCXML)$/) { 662 push @$plugout,"GreenstoneMETSPlugout"; 663 } 664 else{ 665 push @$plugout,$saveas."Plugout"; 666 } 667 } 668 } 669 646 print STDERR "Using plugout specified in collect.cfg: $collectcfg->{'plugout'}\n"; 647 } 648 else { 649 push @$plugout,$saveas."Plugout"; 650 } 651 } 652 670 653 my $plugout_name = $plugout->[0]; 671 654 … … 681 664 682 665 push @$plugout,("-xslt_file",$xsltfile) if (defined $xsltfile && $xsltfile ne ""); 683 666 push @$plugout, ("-no_auxiliary_databases") if ($generate_auxiliary_files == 0); 684 667 if ($inexport_mode eq "import") { 685 668 if ($plugout_name =~ m/^GreenstoneXMLPlugout$/) { … … 687 670 } 688 671 } 689 if ($plugout_name =~ m/^MARCXMLPlugout$/) {690 push @$plugout,("-group") if ($group_marc);691 push @$plugout,("-mapping_file",$mapping_file) if (defined $mapping_file && $mapping_file ne "");692 }693 if ($plugout_name =~ m/^.*METSPlugout$/) {694 push @$plugout,("-xslt_mets",$xslt_mets) if (defined $xslt_mets && $xslt_mets ne "");695 push @$plugout,("-xslt_txt",$xslt_txt) if (defined $xslt_txt && $xslt_txt ne "");696 }697 698 if ($plugout_name eq "FedoraMETSPlugout") {699 push @$plugout,("-fedora_namespace",$fedora_namespace) if (defined $fedora_namespace && $fedora_namespace ne "");700 }701 702 if ($plugout_name eq "DSpacePlugout") {703 push @$plugout,("-metadata_prefix",$metadata_prefix) if (defined $metadata_prefix && $metadata_prefix ne "");704 }705 706 672 my $processor = &plugout::load_plugout($plugout); 707 673 $processor->setoutputdir ($archivedir); 708 674 $processor->set_sortmeta ($sortmeta, $removeprefix, $removesuffix) if defined $sortmeta; 709 710 675 $processor->set_OIDtype ($OIDtype, $OIDmetadata); 711 676 $processor->begin(); 712 677 &plugin::begin($pluginfo, $importdir, $processor, $maxdocs, $gli); 713 678 … … 964 929 # oailastmodified and oailastmodifieddate 965 930 my $earliestDatestampFile = &FileUtils::filenameConcatenate($archivedir, "earliestDatestamp"); 931 if ($self->{'generate_auxiliary_files'}) { 966 932 if (!-f $earliestDatestampFile && -d $archivedir) { 967 933 my $current_time_in_seconds = time; # in seconds … … 977 943 978 944 } 979 945 } 980 946 981 947 $self->perform_process_files($manifest, $pluginfo, $importdir, '', $block_hash, $metadata, $processor, $maxdocs); … … 1014 980 1015 981 # if ($inexport_mode eq "import") { 982 if ($self->{'generate_auxiliary_files'}) { 1016 983 # write out the archive information file 1017 984 # for backwards compatability with archvies.inf file … … 1022 989 $archive_info->save_revinfo_db($arcinfo_src_filename); 1023 990 } 1024 #}991 } 1025 992 return $pluginfo; 1026 993 }
Note:
See TracChangeset
for help on using the changeset viewer.