Index: main/trunk/greenstone2/perllib/inexport.pm
===================================================================
--- main/trunk/greenstone2/perllib/inexport.pm	(revision 28640)
+++ main/trunk/greenstone2/perllib/inexport.pm	(revision 28641)
@@ -48,4 +48,142 @@
 use File::Basename;
 
+my $oidtype_list =
+    [ { 'name' => "hash",
+        'desc' => "{import.OIDtype.hash}" },
+      { 'name' => "hash_on_full_filename",
+        'desc' => "{import.OIDtype.hash_on_full_filename}" },
+      { 'name' => "assigned",
+        'desc' => "{import.OIDtype.assigned}" },
+      { 'name' => "incremental",
+        'desc' => "{import.OIDtype.incremental}" },
+      { 'name' => "filename",
+        'desc' => "{import.OIDtype.filename}" },
+      { 'name' => "dirname",
+        'desc' => "{import.OIDtype.dirname}" },
+      { 'name' => "full_filename",
+        'desc' => "{import.OIDtype.full_filename}" } ];
+
+$inexport::directory_arguments = 
+[
+      { 'name' => "importdir",
+	'desc' => "{import.importdir}",
+	'type' => "string",
+	'reqd' => "no",
+        'hiddengli' => "yes" },
+      { 'name' => "collectdir",
+	'desc' => "{import.collectdir}",
+	'type' => "string",
+	# parsearg left "" as default
+	#'deft' => &FileUtils::filenameConcatenate($ENV{'GSDLHOME'}, "collect"),
+	'deft' => "",
+	'reqd' => "no",
+        'hiddengli' => "yes" },
+ 
+];
+$inexport::arguments = 
+[
+      # don't set the default to hash - want to allow this to come from
+      # entry in collect.cfg but want to override it here 
+      { 'name' => "OIDtype",
+	'desc' => "{import.OIDtype}",
+	'type' => "enum",
+	'list' => $oidtype_list,
+	# parsearg left "" as default
+	#'deft' => "hash",
+	'reqd' => "no",
+	'modegli' => "2" },
+      { 'name' => "OIDmetadata",
+	'desc' => "{import.OIDmetadata}",
+	'type' => "string",
+	 #'type' => "metadata", #doesn't work properly in GLI
+	# parsearg left "" as default
+	#'deft' => "dc.Identifier",
+	'reqd' => "no",
+	'modegli' => "2" },
+      { 'name' => "site",
+	'desc' => "{import.site}",
+	'type' => "string",
+	'deft' => "",
+	'reqd' => "no",
+        'hiddengli' => "yes" },
+      { 'name' => "manifest",
+	'desc' => "{import.manifest}",
+	'type' => "string",
+	'deft' => "",
+	'reqd' => "no",
+        'hiddengli' => "yes" } ,
+     { 'name' => "incremental",
+	'desc' => "{import.incremental}",
+	'type' => "flag",
+	'hiddengli' => "yes" },
+      { 'name' => "keepold",
+	'desc' => "{import.keepold}",
+	'type' => "flag",
+	'reqd' => "no",
+	'hiddengli' => "yes" },
+      { 'name' => "removeold",
+	'desc' => "{import.removeold}",
+	'type' => "flag",
+	'reqd' => "no",
+	'hiddengli' => "yes" },
+      { 'name' => "language",
+	'desc' => "{scripts.language}",
+	'type' => "string",
+	'reqd' => "no",
+	'hiddengli' => "yes" },
+      { 'name' => "maxdocs",
+	'desc' => "{import.maxdocs}",
+	'type' => "int",
+	'reqd' => "no",
+	# parsearg left "" as default
+	#'deft' => "-1",
+	'range' => "1,",
+	'modegli' => "1" },
+       { 'name' => "debug",
+	'desc' => "{import.debug}",
+	'type' => "flag",
+	'reqd' => "no",
+        'hiddengli' => "yes" },
+      { 'name' => "faillog",
+	'desc' => "{import.faillog}",
+	'type' => "string",
+	# parsearg left "" as default
+	#'deft' => &FileUtils::filenameConcatenate("&lt;collectdir&gt;", "colname", "etc", "fail.log"),
+	'deft' => "",
+	'reqd' => "no",
+        'modegli' => "3" },
+       { 'name' => "out",
+	'desc' => "{import.out}",
+	'type' => "string",
+	'deft' => "STDERR",
+	'reqd' => "no",
+        'hiddengli' => "yes" },
+      { 'name' => "statsfile",
+	'desc' => "{import.statsfile}",
+	'type' => "string",
+	'deft' => "STDERR",
+	'reqd' => "no",
+        'hiddengli' => "yes" },
+      { 'name' => "verbosity",
+	'desc' => "{import.verbosity}",
+	'type' => "int",
+	'range' => "0,",
+	# parsearg left "" as default
+	# 'deft' => "2",
+	'reqd' => "no",
+	'modegli' => "3" },
+      { 'name' => "gli",
+	'desc' => "{scripts.gli}",
+	'type' => "flag",
+	'reqd' => "no",
+	'hiddengli' => "yes" },
+      { 'name' => "xml",
+	'desc' => "{scripts.xml}",
+	'type' => "flag",
+	'reqd' => "no",
+	'hiddengli' => "yes" },
+
+];
+
 sub new 
 {
@@ -101,4 +239,5 @@
     if ($intArgLeftinAfterParsing != 1 || (@$argv && $argv->[0] =~ /^\-+h/))
     {
+	## TODO if we had invalid arg, can we signla that to user???
 	&PrintUsage::print_txt_usage($options, "{import.params}");
 	die "\n";
@@ -306,20 +445,5 @@
     }
 
-    if ((defined $self->{'groupsize'}) && ($self->{'groupsize'} == 1)) {
-	if (defined $collectcfg->{'groupsize'} && $collectcfg->{'groupsize'} =~ /\d+/) {
-	    $self->{'groupsize'} = $collectcfg->{'groupsize'};
-	}
-    }
-    
-    if (!defined $self->{'saveas'}
-	|| ($self->{'saveas'} !~ /^(GreenstoneXML|GreenstoneMETS)$/ )) {
-	# saveas was either not defined on the command-line, or it was not one of the recognized values
-	if (defined $collectcfg->{'saveas'} 
-	    && $collectcfg->{'saveas'} =~ /^(GreenstoneXML|GreenstoneMETS)$/) {
-	    $self->{'saveas'} = $collectcfg->{'saveas'};
-	} else {
-	    $self->{'saveas'} = "GreenstoneXML"; # the default
-	}
-    }
+   
 
     if (!defined $self->{'OIDtype'} 
@@ -342,26 +466,4 @@
     }
 
-    my $sortmeta = $self->{'sortmeta'};
-    if (defined $collectcfg->{'sortmeta'} && (!defined $sortmeta || $sortmeta eq "")) {
-	$sortmeta = $collectcfg->{'sortmeta'};
-    }
-    # sortmeta cannot be used with group size
-    $sortmeta = undef unless defined $sortmeta && $sortmeta =~ /\S/;
-    if (defined $sortmeta && $self->{'groupsize'} > 1) {
-	&gsprintf($out, "{import.cannot_sort}\n\n");
-	$sortmeta = undef;
-    }
-	if (defined $sortmeta) {
-	&gsprintf($out, "{import.sortmeta_paired_with_ArchivesInfPlugin}\n\n");	
-    }
-    $self->{'sortmeta'} = $sortmeta;
-
-    if (defined $collectcfg->{'removeprefix'} && $self->{'removeprefix'} eq "") {
-	$self->{'removeprefix'} = $collectcfg->{'removeprefix'};
-    }
-    
-    if (defined $collectcfg->{'removesuffix'} && $self->{'removesuffix'} eq "") {
-	$self->{'removesuffix'} = $collectcfg->{'removesuffix'};
-    }
     if (defined $collectcfg->{'debug'} && $collectcfg->{'debug'} =~ /^true$/i) {
 	$self->{'debug'} = 1;
@@ -391,5 +493,5 @@
       print STDERR "Warning: -manifest flag should not be specified without also setting -keepold or -incremental\n";
     }
-}
+	}
 
 sub process_files
@@ -415,4 +517,5 @@
 
     my $saveas      = $self->{'saveas'};
+    my $saveas_options = $self->{'saveas_options'};
     my $OIDtype     = $self->{'OIDtype'};
     my $OIDmetadata = $self->{'OIDmetadata'};
@@ -549,4 +652,5 @@
 	    }
 	}
+
     }
     else {
@@ -566,8 +670,11 @@
     my $plugout_name = $plugout->[0];
 
+    if ($inexport_mode eq "export" && defined $saveas_options) {
+	my @user_plugout_options = split(" ", $saveas_options);
+	push @$plugout, @user_plugout_options;
+    }
     push @$plugout,("-output_info",$archive_info)  if (defined $archive_info); 
     push @$plugout,("-verbosity",$verbosity)       if (defined $verbosity);
     push @$plugout,("-debug")                      if ($debug);
-    push @$plugout,("-group_size",$groupsize)      if (defined $groupsize);
     push @$plugout,("-gzip_output")                if ($gzip);
     push @$plugout,("-output_handle",$out)         if (defined $out);
@@ -575,4 +682,9 @@
     push @$plugout,("-xslt_file",$xsltfile)        if (defined $xsltfile && $xsltfile ne "");
 
+    if ($inexport_mode eq "import") {
+	if ($plugout_name =~ m/^GreenstoneXMLPlugout$/) {
+	    push @$plugout,("-group_size",$groupsize)      if (defined $groupsize);
+	}
+    }
     if ($plugout_name =~ m/^MARCXMLPlugout$/) {
 	push @$plugout,("-group")                      if ($group_marc);
@@ -898,16 +1010,17 @@
     }
 
-    # write out the archive information file
-    $processor->close_file_output() if (defined $groupsize) && ($groupsize > 1);
+    # signal to the processor (plugout) that we have finished processing - if we are group processing, then the final output file needs closing.
     $processor->close_group_output() if $processor->is_group();
 
-    # for backwards compatability with archvies.inf file
-    if ($arcinfo_doc_filename =~ m/(contents)|(\.inf)$/) {
-	$archive_info->save_info($arcinfo_doc_filename);
-    }
-    else {
-	$archive_info->save_revinfo_db($arcinfo_src_filename);
-    }
-
+#    if ($inexport_mode eq "import") {
+	# write out the archive information file
+	# for backwards compatability with archvies.inf file
+	if ($arcinfo_doc_filename =~ m/(contents)|(\.inf)$/) {
+	    $archive_info->save_info($arcinfo_doc_filename);
+	}
+	else {
+	    $archive_info->save_revinfo_db($arcinfo_src_filename);
+	}
+#    }
     return $pluginfo;
 }
@@ -1380,4 +1493,4 @@
 }
 
-
+    
 1;
