Index: /main/trunk/greenstone2/bin/script/export.pl
===================================================================
--- /main/trunk/greenstone2/bin/script/export.pl	(revision 28638)
+++ /main/trunk/greenstone2/bin/script/export.pl	(revision 28639)
@@ -70,13 +70,5 @@
 use inexport;
 
-my $oidtype_list = 
-    [ { 'name' => "hash",
-        'desc' => "{import.OIDtype.hash}" },
-      { 'name' => "assigned",
-        'desc' => "{import.OIDtype.assigned}" },
-      { 'name' => "incremental",
-        'desc' => "{import.OIDtype.incremental}" },
-      { 'name' => "dirname",
-        'desc' => "{import.OIDtype.dirname}" } ];
+
 
 # what format to export as
@@ -114,4 +106,8 @@
     [ 
       $saveas_argument,
+      { 'name' => "saveas_options",
+	'desc' => "{import.saveas_options}",
+	'type' => "string",
+	'reqd' => "no" },
       { 'name' => "exportdir",
 	'desc' => "{export.exportdir}",
@@ -119,93 +115,5 @@
 	'reqd' => "no",
         'hiddengli' => "yes" },
-      { 'name' => "importdir",
-	'desc' => "{import.importdir}",
-	'type' => "string",
-	'reqd' => "no",
-        'hiddengli' => "yes" },
-      { 'name' => "collectdir",
-	'desc' => "{export.collectdir}",
-	'type' => "string",
-	# parsearg left "" as default
-	#'deft' => &util::filename_cat ($ENV{'GSDLHOME'}, "collect"),
-	'deft' => "",
-	'reqd' => "no",
-	'hiddengli' => "yes" },
-      { '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' => "debug",
-	'desc' => "{export.debug}",
-	'type' => "flag",
-	'reqd' => "no",
-        'hiddengli' => "yes" },
-      { 'name' => "faillog",
-	'desc' => "{export.faillog}",
-	'type' => "string",
-	'deft' => "",
-	'reqd' => "no",
-        'modegli' => "3" },
-      # does this make sense?
-      { 'name' => "incremental",
-	'desc' => "{import.incremental}",
-	'type' => "flag",
-	'hiddengli' => "yes" },
-      { 'name' => "keepold",
-	'desc' => "{export.keepold}",
-	'type' => "flag",
-	'reqd' => "no",
-	'hiddengli' => "yes" },
-      { 'name' => "removeold",
-	'desc' => "{export.removeold}",
-	'type' => "flag",
-	'reqd' => "no",
-	'hiddengli' => "yes" },
-      { 'name' => "language",
-	'desc' => "{scripts.language}",
-	'type' => "string",
-	'reqd' => "no",
-	'hiddengli' => "yes" },
-      { 'name' => "maxdocs",
-	'desc' => "{export.maxdocs}",
-	'type' => "int",
-	'reqd' => "no",
-	'range' => "1,",
-	'modegli' => "1" },
-      { '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
-	'deft' => "dc.Identifier",
-	'reqd' => "no",
-	'modegli' => "2" },
-      { 'name' => "out",
-	'desc' => "{export.out}",
-	'type' => "string",
-	'deft' => "STDERR",
-	'reqd' => "no",
-        'hiddengli' => "yes" },
-      { 'name' => "statsfile",
-	'desc' => "{export.statsfile}",
-	'type' => "string",
-	'deft' => "STDERR",
-	'reqd' => "no",
-        'hiddengli' => "yes" },
+      @$inexport::directory_arguments,
       { 'name' => "xsltfile",
 	'desc' => "{BasPlugout.xslt_file}",
@@ -244,25 +152,9 @@
 	'reqd' => "no",
         'hiddengli' => "no" },
-      { 'name' => "verbosity",
-	'desc' => "{export.verbosity}",
-	'type' => "int",
-	'range' => "0,3",
-	'deft' => "2",
-	'reqd' => "no",
-	'modegli' => "3" },
-      { 'name' => "gli",
-	'desc' => "{scripts.gli}",
-	'type' => "flag",
-	'reqd' => "no",
-	'hiddengli' => "yes" },
       { 'name' => "listall",
 	'desc' => "{export.listall}",
 	'type' => "flag",
 	'reqd' => "no" },
-      { 'name' => "xml",
-	'desc' => "{scripts.xml}",
-	'type' => "flag",
-	'reqd' => "no",
-	'hiddengli' => "yes" }
+      @$inexport::arguments
       ];
 
@@ -287,5 +179,5 @@
 	    = $inexport->read_collection_cfg($collection,$options);    
 
-	$inexport->set_collection_options($collect_cfg);
+	&set_collection_options($inexport, $collect_cfg);
     
 	my $pluginfo = $inexport->process_files($config_filename,$collect_cfg);
@@ -293,8 +185,32 @@
 	$inexport->generate_statistics($pluginfo);
     }
+    
+    $inexport->deinit();
 }
 
-
+sub set_collection_options
+{
+    my ($inexport, $collectcfg) = @_;
+
+    if (!defined $inexport->{'saveas'}) {
+	if (defined $collectcfg->{'saveas'} 
+	    && $collectcfg->{'saveas'} =~ /^(GreenstoneMETS|FedoraMETS|MARCXML|DSPace)$/) {
+	    $inexport->{'saveas'} = $collectcfg->{'saveas'};
+	} else {
+	    $inexport->{'saveas'} = "GreenstoneMETS"; # the default
+	}
+    }
+
+    if (!defined $inexport->{'saveas_options'}) {
+	if (defined $collectcfg->{'saveas_options'} ){
+	    $inexport->{'saveas'} = $collectcfg->{'saveas_options'};
+	}
+    }
+
+    $inexport->set_collection_options($collectcfg);
+}
 &main();
 
 
+
+ 
Index: /main/trunk/greenstone2/bin/script/import.pl
===================================================================
--- /main/trunk/greenstone2/bin/script/import.pl	(revision 28638)
+++ /main/trunk/greenstone2/bin/script/import.pl	(revision 28639)
@@ -79,19 +79,4 @@
 use util;
 
-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}" } ];
 
 
@@ -126,99 +111,5 @@
     [ 
       $saveas_argument,
-      { 'name' => "archivedir",
-	'desc' => "{import.archivedir}",
-	'type' => "string",
-	'reqd' => "no",
-        'hiddengli' => "yes" },
-      { '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" },
-      { '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' => "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' => "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" },
-      # 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' => "out",
-	'desc' => "{import.out}",
-	'type' => "string",
-	'deft' => "STDERR",
-	'reqd' => "no",
-        'hiddengli' => "yes" },
-      { 'name' => "sortmeta",
+    { 'name' => "sortmeta",
 	'desc' => "{import.sortmeta}",
 	'type' => "string",
@@ -244,4 +135,10 @@
 	'reqd' => "no",
 	'modegli' => "2" },
+      { 'name' => "archivedir",
+	'desc' => "{import.archivedir}",
+	'type' => "string",
+	'reqd' => "no",
+        'hiddengli' => "yes" },
+      @$inexport::directory_arguments,
       { 'name' => "gzip",
 	'desc' => "{import.gzip}",
@@ -249,28 +146,6 @@
 	'reqd' => "no",
 	'modegli' => "3" },
-      { '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" }];
+     @$inexport::arguments
+];
 
 my $options = { 'name' => "import.pl",
@@ -337,5 +212,6 @@
     my ($config_filename,$collect_cfg) = $inexport->read_collection_cfg($collection,$options);
 
-    $inexport->set_collection_options($collect_cfg);
+    #$inexport->set_collection_options($collect_cfg);
+    &set_collection_options($inexport, $collect_cfg);
 
     my $pluginfo = $inexport->process_files($config_filename,$collect_cfg);
@@ -400,3 +276,53 @@
 # _scanForInExportModules()
 
+# look up collect.cfg for import options, then all inexport version for the 
+# common ones
+sub set_collection_options
+{
+
+    my ($inexport, $collectcfg) = @_;
+
+    #groupsize can (currently) only be defined for import, not export, and 
+    # will be set to 1 if the user has not set it
+    if ((defined $inexport->{'groupsize'}) && ($inexport->{'groupsize'} == 1)) {
+	if (defined $collectcfg->{'groupsize'} && $collectcfg->{'groupsize'} =~ /\d+/) {
+	    $inexport->{'groupsize'} = $collectcfg->{'groupsize'};
+	}
+    }
+
+    if (!defined $inexport->{'saveas'}) {
+	if (defined $collectcfg->{'saveas'} 
+	    && $collectcfg->{'saveas'} =~ /^(GreenstoneXML|GreenstoneMETS)$/) {
+	    $inexport->{'saveas'} = $collectcfg->{'saveas'};
+	} else {
+	    $inexport->{'saveas'} = "GreenstoneXML"; # the default
+	}
+    }
+    
+    my $sortmeta = $inexport->{'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 && $inexport->{'groupsize'} > 1) {
+	&gsprintf($out, "{import.cannot_sort}\n\n");
+	$sortmeta = undef;
+    }
+    if (defined $sortmeta) {
+	&gsprintf($out, "{import.sortmeta_paired_with_ArchivesInfPlugin}\n\n");	
+    }
+    $inexport->{'sortmeta'} = $sortmeta;
+
+    if (defined $collectcfg->{'removeprefix'} && $inexport->{'removeprefix'} eq "") {
+	$inexport->{'removeprefix'} = $collectcfg->{'removeprefix'};
+    }
+    
+    if (defined $collectcfg->{'removesuffix'} && $inexport->{'removesuffix'} eq "") {
+	$inexport->{'removesuffix'} = $collectcfg->{'removesuffix'};
+    }
+
+    $inexport->set_collection_options($collectcfg);
+ 
+}
 &main();
