changeset 17:6c5c7743acb1

new version with new -onlinne-mode for online/permanent.
author casties
date Wed, 31 Aug 2005 12:50:00 +0200
parents 8eee361fdec8
children fdf4ceb36db1
files makemeta-lib.pl
diffstat 1 files changed, 26 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/makemeta-lib.pl	Tue Aug 23 17:01:08 2005 +0200
+++ b/makemeta-lib.pl	Wed Aug 31 12:50:00 2005 +0200
@@ -10,13 +10,14 @@
 $|=1;
 
 # program version
-my $version = "0.2.1 (15.8.2005)";
+my $version = "0.2.2 (31.8.2005 ROC)";
 my $help = 
 "use: makemeta-lib [options] file.xml
 options:
   -debug  show debugging info
   -dry-run  simulate, dont'do anything
-  -cw-mode  mode for copying einstein_cq documents
+  -online-mode  mode for creating online/permanent files
+  -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)
 ";
@@ -135,6 +136,10 @@
 my $dry_run = (exists $$args{'dry-run'}) ? $$args{'dry-run'} : 0;
 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");
+
 # use einstein-cw mode
 my $cw_mode = (exists $$args{'cw-mode'}) ? $$args{'cw-mode'} : 0;
 logger('DEBUG', "cw_mode: $cw_mode");
@@ -266,6 +271,20 @@
     return;
 }
 
+sub find_permanent_dir {
+    my ($input_node) = @_;
+    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) {
+	logger('ERROR', "no ID field for online permanent entry");
+	$errcnt++;
+	return;
+    }
+    my $dir = "$online_base/$src_dir";
+    return $dir;
+}
+
 #
 # $dir = find_online_dir($input_node, $base_dir, $page_dir)
 #
@@ -289,12 +308,13 @@
     }
     #logger('DEBUG', "online_dir1: $online_dir");
     if ($online_dir) {
+	$online_dir =~ s/\/$//; # strip ending slashes
 	if ($page_dir) {
 	  $online_dir =~ s/\/${page_dir}$//;
 	}
 	#logger("DEBUG", "dir: $base_dir/$online_dir");
 	if (-d "$base_dir/$online_dir") {
-	    logger('DEBUG', "directory $base_dir/$online_dir exists"); 
+	    logger('DEBUG', "directory $base_dir/$online_dir exists");
 	    return $online_dir;
 	}
     }
@@ -400,7 +420,9 @@
 
     # try to find the document directory
     my $doc_dir = "";
-    if ($cw_mode) {
+    if ($online_mode) {
+	$doc_dir = find_permanent_dir($input_node);
+    } elsif ($cw_mode) {
 	$doc_dir = find_cw_dir($input_node);
     } elsif ($digifiles_mode) {
 	$doc_dir = find_digifiles_dir($input_node);