--- foxridge-archiver/makemeta-lib.pl 2006/05/16 19:56:32 1.9 +++ foxridge-archiver/makemeta-lib.pl 2006/12/11 18:07:43 1.12 @@ -10,13 +10,14 @@ use MPIWGStor; $|=1; # program version -my $version = "0.2.4 (16.5.2006 ROC)"; +my $version = "0.2.6 (11.12.2006 ROC)"; my $help = "use: makemeta-lib [options] file.xml options: -debug show debugging info -dry-run simulate, dont'do anything -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 -digifiles-mode mode for copying files from digifiles -map-file=mapfile.xml digilib mapping file (for digifiles mode) @@ -106,7 +107,8 @@ my %lang_map = ( 'Latin' => 'la', 'Japanese' => 'ja', 'Dutch' => 'nl', - 'Spanish' => 'es' + 'Spanish' => 'es', + 'Swedish' => 'sv' ); # storage fields my $arch_id_field = 'ID_Archive'; @@ -140,6 +142,9 @@ logger('DEBUG', "dry-run: $dry_run"); # use online mode my $online_mode = (exists $$args{'online-mode'}) ? $$args{'online-mode'} : 0; 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 my $cw_mode = (exists $$args{'cw-mode'}) ? $$args{'cw-mode'} : 0; @@ -174,7 +179,7 @@ if (! $infile) { exit 1; } # strip double slashes -$infile =~ s/\/\//\//; +$infile = sstrip($infile, 1); if (! -f $infile) { logger("ABORT", "input file \'$infile\' doesn't exist!"); exit 1; @@ -277,15 +282,21 @@ sub find_cw_dir { sub find_permanent_dir { 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 $src_dir = find_online_dir($input_node, $online_base, 'pageimg'); - my $dest_id = sstrip($input_node->findvalue("fm:$online_id_field")); - if ((! $dest_id)||(! $src_dir)) { - logger('ERROR', "no ID field for online permanent entry"); + my $online_dir = find_online_dir($input_node, $online_base, 'pageimg'); + if ((! $online_dir)) { + logger('ERROR', "no ID or URL for online permanent entry"); $errcnt++; return; } - my $dir = "$online_base/$src_dir"; + my $dir = sstrip("$online_base/$online_dir", 1); return $dir; } @@ -314,7 +325,8 @@ sub find_online_dir { if ($online_dir) { $online_dir =~ s/\/$//; # strip ending slashes if ($page_dir) { - $online_dir =~ s/\/${page_dir}$//; + # strip page_dir + $online_dir =~ s/\/${page_dir}$//; } #logger("DEBUG", "dir: $base_dir/$online_dir"); if (-d "$base_dir/$online_dir") { @@ -463,9 +475,9 @@ sub process_fm_entry { # access if ($access_type) { 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 { - 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); } }