|
|
| version 1.9, 2006/05/16 19:56:32 | version 1.13, 2017/03/16 17:00:43 |
|---|---|
| Line 1 | Line 1 |
| #!/usr/local/bin/perl -w | #!/usr/bin/perl -w |
| use strict; | use strict; |
| use XML::LibXML; | use XML::LibXML; |
| Line 10 use MPIWGStor; | Line 10 use MPIWGStor; |
| $|=1; | $|=1; |
| # program version | # program version |
| my $version = "0.2.4 (16.5.2006 ROC)"; | my $version = "0.2.6 (11.12.2006 ROC)"; |
| my $help = | my $help = |
| "use: makemeta-lib [options] file.xml | "use: makemeta-lib [options] file.xml |
| options: | options: |
| -debug show debugging info | -debug show debugging info |
| -dry-run simulate, dont'do anything | -dry-run simulate, dont'do anything |
| -online-mode mode for creating online/permanent files | -online-mode mode for creating online/permanent files |
| -online-base=dir base directory for online ids (for online mode) | |
| -cw-mode mode for copying einstein_cw archive documents | -cw-mode mode for copying einstein_cw archive documents |
| -digifiles-mode mode for copying files from digifiles | -digifiles-mode mode for copying files from digifiles |
| -map-file=mapfile.xml digilib mapping file (for digifiles mode) | -map-file=mapfile.xml digilib mapping file (for digifiles mode) |
| Line 106 my %lang_map = ( | Line 107 my %lang_map = ( |
| 'Latin' => 'la', | 'Latin' => 'la', |
| 'Japanese' => 'ja', | 'Japanese' => 'ja', |
| 'Dutch' => 'nl', | 'Dutch' => 'nl', |
| 'Spanish' => 'es' | 'Spanish' => 'es', |
| 'Swedish' => 'sv' | |
| ); | ); |
| # storage fields | # storage fields |
| my $arch_id_field = 'ID_Archive'; | my $arch_id_field = 'ID_Archive'; |
| Line 140 logger('DEBUG', "dry-run: $dry_run"); | Line 142 logger('DEBUG', "dry-run: $dry_run"); |
| # use online mode | # use online mode |
| my $online_mode = (exists $$args{'online-mode'}) ? $$args{'online-mode'} : 0; | my $online_mode = (exists $$args{'online-mode'}) ? $$args{'online-mode'} : 0; |
| logger('DEBUG', "online_mode: $online_mode"); | logger('DEBUG', "online_mode: $online_mode"); |
| # online base dir | |
| my $online_base_dir = (exists $$args{'online-base'}) ? $$args{'online-base'} : ""; | |
| logger('DEBUG', "online_base_dir: $online_base_dir"); | |
| # use einstein-cw mode | # use einstein-cw mode |
| my $cw_mode = (exists $$args{'cw-mode'}) ? $$args{'cw-mode'} : 0; | my $cw_mode = (exists $$args{'cw-mode'}) ? $$args{'cw-mode'} : 0; |
| Line 174 if (! $infile) { | Line 179 if (! $infile) { |
| exit 1; | exit 1; |
| } | } |
| # strip double slashes | # strip double slashes |
| $infile =~ s/\/\//\//; | $infile = sstrip($infile, 1); |
| if (! -f $infile) { | if (! -f $infile) { |
| logger("ABORT", "input file \'$infile\' doesn't exist!"); | logger("ABORT", "input file \'$infile\' doesn't exist!"); |
| exit 1; | exit 1; |
| Line 277 sub find_cw_dir { | Line 282 sub find_cw_dir { |
| sub find_permanent_dir { | sub find_permanent_dir { |
| my ($input_node) = @_; | my ($input_node) = @_; |
| my $online_id = sstrip($input_node->findvalue("fm:$online_id_field")); | |
| # try online_base_dir + online_id first | |
| if (($online_base_dir)&&($online_id)) { | |
| my $dir = sstrip("$online_base_dir/$online_id", 1); | |
| return $dir; | |
| } | |
| # then online_url | |
| my $online_base = '/mpiwg/online/permanent'; | my $online_base = '/mpiwg/online/permanent'; |
| my $src_dir = find_online_dir($input_node, $online_base, 'pageimg'); | my $online_dir = find_online_dir($input_node, $online_base, 'pageimg'); |
| my $dest_id = sstrip($input_node->findvalue("fm:$online_id_field")); | if ((! $online_dir)) { |
| if ((! $dest_id)||(! $src_dir)) { | logger('ERROR', "no ID or URL for online permanent entry"); |
| logger('ERROR', "no ID field for online permanent entry"); | |
| $errcnt++; | $errcnt++; |
| return; | return; |
| } | } |
| my $dir = "$online_base/$src_dir"; | my $dir = sstrip("$online_base/$online_dir", 1); |
| return $dir; | return $dir; |
| } | } |
| Line 314 sub find_online_dir { | Line 325 sub find_online_dir { |
| if ($online_dir) { | if ($online_dir) { |
| $online_dir =~ s/\/$//; # strip ending slashes | $online_dir =~ s/\/$//; # strip ending slashes |
| if ($page_dir) { | if ($page_dir) { |
| # strip page_dir | |
| $online_dir =~ s/\/${page_dir}$//; | $online_dir =~ s/\/${page_dir}$//; |
| } | } |
| #logger("DEBUG", "dir: $base_dir/$online_dir"); | #logger("DEBUG", "dir: $base_dir/$online_dir"); |
| Line 463 sub process_fm_entry { | Line 475 sub process_fm_entry { |
| # access | # access |
| if ($access_type) { | if ($access_type) { |
| if ($access_type eq "free") { | if ($access_type eq "free") { |
| create_element_path('access-conditions/access@type=free', $index_root, $namespace); | create_element_path('meta/access-conditions/access@type=free', $index_root, $namespace); |
| } else { | } else { |
| my $acc_tag = create_element_path('access-conditions/access@type=institution', $index_root, $namespace); | my $acc_tag = create_element_path('meta/access-conditions/access@type=institution', $index_root, $namespace); |
| create_text_path('name', $access_type, $acc_tag, $namespace); | create_text_path('name', $access_type, $acc_tag, $namespace); |
| } | } |
| } | } |