source: gsdl/trunk/bin/script/export.pl@ 14942

Last change on this file since 14942 was 14942, checked in by davidb, 16 years ago

Modification to support extensions. BEGIN block now adds perllib/ perllib/cpan to @INC for each extension.

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 20.0 KB
RevLine 
[8879]1#!/usr/bin/perl -w
2
3###########################################################################
4#
5# export.pl --
6# A component of the Greenstone digital library software
7# from the New Zealand Digital Library Project at the
8# University of Waikato, New Zealand.
9#
10# Copyright (C) 1999 New Zealand Digital Library Project
11#
12# This program is free software; you can redistribute it and/or modify
13# it under the terms of the GNU General Public License as published by
14# the Free Software Foundation; either version 2 of the License, or
15# (at your option) any later version.
16#
17# This program is distributed in the hope that it will be useful,
18# but WITHOUT ANY WARRANTY; without even the implied warranty of
19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20# GNU General Public License for more details.
21#
22# You should have received a copy of the GNU General Public License
23# along with this program; if not, write to the Free Software
24# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25#
26###########################################################################
27
28
29# This program will export a particular collection into a specific Format (e.g. METS or DSpace)
30# Author: Chi-Yu Huang Date: 08-10-2004
31
32package export;
33
34BEGIN {
35 die "GSDLHOME not set\n" unless defined $ENV{'GSDLHOME'};
36 die "GSDLOS not set\n" unless defined $ENV{'GSDLOS'};
37 unshift (@INC, "$ENV{'GSDLHOME'}/perllib");
38 unshift (@INC, "$ENV{'GSDLHOME'}/perllib/cpan");
39 unshift (@INC, "$ENV{'GSDLHOME'}/perllib/plugins");
[12333]40 unshift (@INC, "$ENV{'GSDLHOME'}/perllib/plugouts");
[8879]41 unshift (@INC, "$ENV{'GSDLHOME'}/perllib/classify");
[14942]42
43 if (defined $ENV{'GSDLEXTS'}) {
44 my @extensions = split(/:/,$ENV{'GSDLEXTS'});
45 foreach my $e (@extensions) {
46 my $ext_prefix = "$ENV{'GSDLHOME'}/ext/$e";
47
48 unshift (@INC, "$ext_prefix/perllib");
49 unshift (@INC, "$ext_prefix/perllib/cpan");
50 }
51 }
[8879]52}
53
[10340]54use strict;
55no strict 'refs'; # allow filehandles to be variables and vice versa
56no strict 'subs'; # allow barewords (eg STDERR) as function arguments
57
[10162]58use arcinfo;
[8879]59use colcfg;
60use plugin;
[12333]61use plugout;
[14935]62use manifest;
[8879]63use util;
[10417]64use scriptutil;
[8879]65use FileHandle;
[14935]66use gsprintf 'gsprintf';
[8879]67use printusage;
[10340]68use parse2;
[8879]69
[10340]70
[8879]71my $oidtype_list =
72 [ { 'name' => "hash",
[12691]73 'desc' => "{import.OIDtype.hash}" },
[14935]74 { 'name' => "assigned",
75 'desc' => "{import.OIDtype.assigned}" },
[8879]76 { 'name' => "incremental",
[12691]77 'desc' => "{import.OIDtype.incremental}" },
78 { 'name' => "dirname",
79 'desc' => "{import.OIDtype.dirname}" } ];
[8879]80
81#** define to use the METS format or DSpace format
82my $saveas_list =
83 [ { 'name' => "DSpace",
84 'desc' => "{export.saveas.DSpace}" },
[14935]85 { 'name' => "GreenstoneMETS",
86 'desc' => "{export.saveas.GreenstoneMETS}"},
87 { 'name' => "FedoraMETS",
88 'desc' => "{export.saveas.FedoraMETS}"},
[12333]89 { 'name' => "GA",
90 'desc' => "{export.saveas.GA}"},
91 { 'name' => "MARCXML",
92 'desc' => "{export.saveas.MARCXML}"}
93 ];
[8879]94
95
96# Possible attributes for each argument
97# name: The name of the argument
98# desc: A description (or more likely a reference to a description) for this argument
[12361]99# type: The type of control used to represent the argument. Options include: string, int, flag, regexp, metadata, language, enum etc
[8879]100# reqd: Is this argument required?
101# hiddengli: Is this argument hidden in GLI?
102# modegli: The lowest detail mode this argument is visible at in GLI
103
[14935]104my $saveas_argument =
[9233]105 { 'name' => "saveas",
106 'desc' => "{export.saveas}",
107 'type' => "enum",
108 'list' => $saveas_list,
109 'deft' => "METS",
110 'reqd' => "no",
111 'modegli' => "3" };
112
113
[8879]114my $arguments =
[10340]115 [
116 $saveas_argument,
117 { 'name' => "exportdir",
[8879]118 'desc' => "{export.exportdir}",
119 'type' => "string",
120 'reqd' => "no",
121 'hiddengli' => "yes" },
[10340]122 { 'name' => "importdir",
123 'desc' => "{import.importdir}",
124 'type' => "string",
125 'reqd' => "no",
126 'hiddengli' => "yes" },
[14925]127 { 'name' => "site",
128 'desc' => "{import.site}",
129 'type' => "string",
130 'deft' => "",
131 'reqd' => "no",
132 'hiddengli' => "yes" },
[8879]133 { 'name' => "collectdir",
134 'desc' => "{export.collectdir}",
135 'type' => "string",
[14925]136 # parsearg left "" as default
137 #'deft' => &util::filename_cat ($ENV{'GSDLHOME'}, "collect"),
[14935]138 'deft' => "",
139 'reqd' => "no",
140 'hiddengli' => "yes" },
141 { 'name' => "manifest",
142 'desc' => "{import.manifest}",
143 'type' => "string",
144 'deft' => "",
145 'reqd' => "no",
[8879]146 'hiddengli' => "yes" },
[9233]147 { 'name' => "listall",
[12691]148 'desc' => "{export.listall}",
[9233]149 'type' => "flag",
150 'reqd' => "no" },
[8879]151 { 'name' => "debug",
152 'desc' => "{export.debug}",
153 'type' => "flag",
154 'reqd' => "no",
155 'hiddengli' => "yes" },
156 { 'name' => "faillog",
157 'desc' => "{export.faillog}",
158 'type' => "string",
[10340]159 'deft' => "",
[8879]160 'reqd' => "no",
161 'modegli' => "4" },
[14935]162 { 'name' => "incremental",
163 'desc' => "{import.incremental}",
164 'type' => "flag",
165 'hiddengli' => "yes" },
[8879]166 { 'name' => "keepold",
167 'desc' => "{export.keepold}",
168 'type' => "flag",
169 'reqd' => "no",
[14935]170 'hiddengli' => "yes" },
[10340]171 { 'name' => "removeold",
172 'desc' => "{export.removeold}",
173 'type' => "flag",
174 'reqd' => "no",
175 'modegli' => "3" },
[8879]176 { 'name' => "language",
177 'desc' => "{scripts.language}",
178 'type' => "string",
179 'reqd' => "no",
180 'modegli' => "4" },
181 { 'name' => "maxdocs",
182 'desc' => "{export.maxdocs}",
183 'type' => "int",
184 'reqd' => "no",
185 'range' => "1,",
186 'modegli' => "1" },
[12691]187 { 'name' => "OIDtype",
188 'desc' => "{import.OIDtype}",
189 'type' => "enum",
190 'list' => $oidtype_list,
191 # parsearg left "" as default
192 #'deft' => "hash",
193 'reqd' => "no",
194 'modegli' => "3" },
195 { 'name' => "OIDmetadata",
196 'desc' => "{import.OIDmetadata}",
197 'type' => "metadata",
198 'deft' => "dc.Identifier",
199 'reqd' => "no",
200 'modegli' => "3" },
[8879]201 { 'name' => "out",
202 'desc' => "{export.out}",
203 'type' => "string",
204 'deft' => "STDERR",
205 'reqd' => "no",
206 'hiddengli' => "yes" },
[9951]207 { 'name' => "statsfile",
208 'desc' => "{export.statsfile}",
209 'type' => "string",
210 'deft' => "STDERR",
211 'reqd' => "no",
212 'hiddengli' => "yes" },
[12333]213 { 'name' => "xsltfile",
214 'desc' => "{BasPlugout.xslt_file}",
215 'type' => "string",
216 'reqd' => "no",
217 'hiddengli' => "yes" },
218 { 'name' => "xslt_txt",
219 'desc' => "{METSPlugout.xslt_txt}",
220 'type' => "string",
221 'reqd' => "no",
222 'hiddengli' => "no" },
223 { 'name' => "xslt_mets",
224 'desc' => "{METSPlugout.xslt_mets}",
225 'type' => "string",
226 'reqd' => "no",
227 'hiddengli' => "no" },
[14935]228 { 'name' => "fedora_namespace",
229 'desc' => "{FedoraMETSPlugout.fedora_namespace}",
230 'type' => "string",
231 'deft' => "greenstone",
232 'reqd' => "no",
233 'hiddengli' => "no" },
[12598]234 { 'name' => "mapping_file",
235 'desc' => "{MARCXMLPlugout.mapping_file}",
236 'type' => "string",
237 'reqd' => "no",
238 'hiddengli' => "no" },
[12333]239 { 'name' => "group_marc",
240 'desc' => "{MARCXMLPlugout.group}",
241 'type' => "flag",
242 'reqd' => "no",
243 'hiddengli' => "no" },
[8879]244 { 'name' => "verbosity",
245 'desc' => "{export.verbosity}",
246 'type' => "int",
247 'range' => "0,3",
248 'deft' => "2",
249 'reqd' => "no",
[10340]250 'modegli' => "4" },
251 { 'name' => "gli",
252 'desc' => "",
253 'type' => "flag",
254 'reqd' => "no",
255 'hiddengli' => "yes" },
256 { 'name' => "xml",
257 'desc' => "{scripts.xml}",
258 'type' => "flag",
259 'reqd' => "no",
260 'hiddengli' => "yes" }
261 ];
[8879]262
263my $options = { 'name' => "export.pl",
264 'desc' => "{export.desc}",
265 'args' => $arguments };
266
[9233]267my $listall_options = { 'name' => "export.pl",
268 'desc' => "{export.desc}",
269 'args' => [ $saveas_argument ] };
270
[14935]271#sub gsprintf
272#{
273# return &gsprintf::gsprintf(@_);
274#}
275
276
277sub store_collectionmeta
[8879]278{
[14935]279 my ($collectionmeta,$field,$doc_obj) = @_;
280
281 my $section = $doc_obj->get_top_section();
282
283 my $field_hash = $collectionmeta->{$field};
284
285 foreach my $k (keys %$field_hash)
286 {
287 my $val = $field_hash->{$k};
288
289
290### print STDERR "*** $k = $field_hash->{$k}\n";
291
292 my $md_label = "ex.$field";
293
294
295 if ($k =~ m/^\[l=(.*?)\]$/)
296 {
297
298 my $md_suffix = $1;
299 $md_label .= "^$md_suffix";
300 }
301
302
303 $doc_obj->add_utf8_metadata($section,$md_label, $val);
304
305 if (($md_label eq "ex.collectionname^en") || ($md_label eq "ex.collectionname"))
306 {
307 $doc_obj->add_utf8_metadata($section,"dc.Title", $val);
308 }
309
310 }
[8879]311}
312
313
314&main();
315
316sub main {
[10340]317 # params
[14935]318 my ($language, $verbosity, $debug,
319 $importdir, $manifest, $incremental, $keepold,
320 $exportdir, $site, $listall,
321 $removeold, $saveas,
322 $OIDtype, $OIDmetadata,
323 $out, $faillog, $collectdir, $gli,
324 $gs_mode, $collectcfg,
325 $maxdocs, $statsfile,
326 $mapping_file,
327 $xsltfile,
328 $xslt_mets, $xslt_txt, $fedora_namespace, $group_marc);
329
[8879]330 my $xml = 0;
[10340]331
332 # other vars
[14935]333 my ($configfilename, $collection,
334 $export_info_filename, $export_info,
335 $processor, $pluginfo);
336
[8879]337 my $service = "export";
338
[10340]339 my $hashParsingResult = {};
340 # general options available to all plugins
341 my $intArgLeftinAfterParsing = parse2::parse(\@ARGV,$arguments,$hashParsingResult,"allow_extra_options");
[12545]342
343 # If parse returns -1 then something has gone wrong
344 if ($intArgLeftinAfterParsing == -1)
345 {
346 &PrintUsage::print_txt_usage($options, "{export.params}");
347 die "\n";
348 }
349
[10340]350 foreach my $strVariable (keys %$hashParsingResult)
351 {
352 eval "\$$strVariable = \$hashParsingResult->{\"\$strVariable\"}";
[8879]353 }
354
[10340]355
356 # these are options used by other things - we just set default values
357 # undef means will be set from config file if there
358 my $gzip = undef;
359 my $groupsize = 1;
[12691]360 #my $OIDtype = undef;
[10340]361 my $sortmeta = undef;
[9233]362
[9235]363 my $explicit_exportdir = (defined $exportdir) ? 1 : 0;
364
[10417]365 # save these command line settings. don't want config file settings in one
366 # coll used for other colls
367 # does this apply to other vars???
368 my $global_removeold = $removeold;
369 my $global_keepold = $keepold;
[8879]370 # If $language has been specified, load the appropriate resource bundle
371 # (Otherwise, the default resource bundle will be loaded automatically)
372 if ($language) {
373 &gsprintf::load_language_specific_resource_bundle($language);
374 }
375
[9233]376 if ($listall) {
377 if ($xml) {
378 &PrintUsage::print_xml_usage($listall_options);
379 }
380 else
381 {
382 &PrintUsage::print_txt_usage($listall_options,"{export.params}");
383 }
384 die "\n";
385 }
386 elsif ($xml) {
[8879]387 &PrintUsage::print_xml_usage($options);
388 die "\n";
389 }
390
[12545]391 # can have more than one collection name,
392 # if the first extra option is -h, then output the help
393 if (scalar(@ARGV) == 0 || (@ARGV && $ARGV[0] =~ /^\-+h/)) {
[10340]394 &PrintUsage::print_txt_usage($options, "{export.params}");
395 die "\n";
396 }
397
[8879]398 if ($gli) { # the gli wants strings to be in UTF-8
399 &gsprintf::output_strings_in_UTF8;
400 }
401 my $close_out = 0;
402 if ($out !~ /^(STDERR|STDOUT)$/i) {
403 open (OUT, ">$out") ||
404 (&gsprintf(STDERR, "{common.cannot_open_output_file}\n", $out) && die);
405 $out = 'export::OUT';
406 $close_out = 1;
407 }
408 $out->autoflush(1);
409
[9233]410 while (scalar(@ARGV)>0) {
411 my $collect_name = shift @ARGV;
412 $ENV{'GSDLCOLLECTION'} = $collect_name;
[8879]413
[9233]414 eval {
415 # get and check the collection name
[14925]416 if (($collection = &colcfg::use_collection($site, $collect_name, $collectdir)) eq "") {
[9233]417 &PrintUsage::print_txt_usage($options, "{export.params}");
418 die "\n";
419 }
[12358]420 # add collection's perllib dir into include path in
421 # case we have collection specific modules
422 unshift (@INC, "$ENV{'GSDLCOLLECTDIR'}/perllib");
423
[9233]424 if ($faillog eq "") {
425 $faillog = &util::filename_cat($ENV{'GSDLCOLLECTDIR'}, "etc", "fail.log");
426 }
427 open (FAILLOG, ">$faillog") ||
428 (&gsprintf(STDERR, "{export.cannot_open_fail_log}\n", $faillog) && die);
429 my $faillogname = $faillog;
430 $faillog = 'export::FAILLOG';
431 $faillog->autoflush(1);
432
433 # check sortmeta
434 $sortmeta = undef unless defined $sortmeta && $sortmeta =~ /\S/;
435 if (defined $sortmeta && $groupsize > 1) {
436 &gsprintf($out, "{export.cannot_sort}\n\n");
437 $sortmeta = undef;
438 }
439
440 # get the list of plugins for this collection and set any options that
441 # were specified in the collect.cfg (all export.pl options except
442 # -collectdir, -out and -faillog may be specified in the collect.cfg (these
443 # options must be known before we read the collect.cfg))
444 my $plugins = [];
445 my @global_opts = ();
[14935]446
[14925]447 # Read in the collection configuration file.
448 ($configfilename, $gs_mode) = &colcfg::get_collect_cfg_name($out);
[14935]449
[14925]450 if ($gs_mode eq "gs2") {
451 $collectcfg = &colcfg::read_collect_cfg ($configfilename);
452 } elsif ($gs_mode eq "gs3") {
453 $collectcfg = &colcfg::read_collection_cfg_xml ($configfilename);
[10417]454 }
[14925]455
[14935]456 if (defined $collectcfg->{'importdir'} && $importdir eq "") {
457 $importdir = $collectcfg->{'importdir'};
458 }
459 if (defined $collectcfg->{'exportdir'} && $exportdir eq "") {
460 $exportdir = $collectcfg->{'exportdir'};
461 }
462
463 # fill in the default import and export directories if none
464 # were supplied, turn all \ into / and remove trailing /
465 $importdir = &util::filename_cat ($ENV{'GSDLCOLLECTDIR'}, "import") if $importdir eq "";
466 $importdir =~ s/[\\\/]+/\//g;
467 $importdir =~ s/\/$//;
468 if (!-e $importdir) {
469 &gsprintf($out, "{import.no_import_dir}\n\n", $importdir);
470 die "\n";
471 }
472
473 $exportdir = &util::filename_cat ($ENV{'GSDLCOLLECTDIR'}, "export") if $exportdir eq "";
474 $exportdir =~ s/[\\\/]+/\//g;
475 $exportdir =~ s/\/$//;
476
[10417]477 if (defined $collectcfg->{'plugin'}) {
478 $plugins = $collectcfg->{'plugin'};
479 }
480
481 if ($verbosity !~ /\d+/) {
482 if (defined $collectcfg->{'verbosity'} && $collectcfg->{'verbosity'} =~ /\d+/) {
483 $verbosity = $collectcfg->{'verbosity'};
484 } else {
485 $verbosity = 2; # the default
[9233]486 }
[10417]487 }
488
489 if (defined $collectcfg->{'gzip'} && !$gzip) {
490 if ($collectcfg->{'gzip'} =~ /^true$/i) {
491 $gzip = 1;
[9233]492 }
[10417]493 }
494 if ($maxdocs !~ /\-?\d+/) {
495 if (defined $collectcfg->{'maxdocs'} && $collectcfg->{'maxdocs'} =~ /\-?\d+/) {
496 $maxdocs = $collectcfg->{'maxdocs'};
497 } else {
498 $maxdocs = -1; # the default
[9233]499 }
[10417]500 }
501 if ($groupsize == 1) {
502 if (defined $collectcfg->{'groupsize'} && $collectcfg->{'groupsize'} =~ /\d+/) {
503 $groupsize = $collectcfg->{'groupsize'};
[9233]504 }
[10417]505 }
[12691]506 if (!defined $OIDtype || ($OIDtype !~ /^(hash|incremental|assigned|dirname)$/)) {
[10417]507 if (defined $collectcfg->{'OIDtype'} && $collectcfg->{'OIDtype'} =~ /^(hash|incremental)$/) {
508 $OIDtype = $collectcfg->{'OIDtype'};
509 } else {
510 $OIDtype = "hash"; # the default
[9233]511 }
[8879]512 }
[10417]513 if (defined $collectcfg->{'sortmeta'} && $sortmeta eq "") {
514 $sortmeta = $collectcfg->{'sortmeta'};
515 }
516 if (defined $collectcfg->{'debug'} && $collectcfg->{'debug'} =~ /^true$/i) {
517 $debug = 1;
518 }
519 if (defined $collectcfg->{'gli'} && $collectcfg->{'gli'} =~ /^true$/i) {
520 $gli = 1;
521 }
[9233]522
[10417]523 # global plugin stuff
524 if (defined $collectcfg->{'separate_cjk'}&& $collectcfg->{'separate_cjk'} =~ /^true$/i) {
525 push @global_opts, "-separate_cjk";
526 }
527
[12965]528 ($removeold, $keepold) = &scriptutil::check_removeold_and_keepold($global_removeold, $global_keepold, 0, "export", $collectcfg);
[10417]529
[9233]530 $gli = 0 unless defined $gli;
531
532 print STDERR "<export>\n" if $gli;
533
534 # fill in the default import and export directories if none
535 # were supplied, turn all \ into / and remove trailing /
536 $importdir = &util::filename_cat ($ENV{'GSDLCOLLECTDIR'}, "import") if $importdir eq "";
537 $importdir =~ s/[\\\/]+/\//g;
538 $importdir =~ s/\/$//;
539 $exportdir = &util::filename_cat ($ENV{'GSDLCOLLECTDIR'}, "export") if $exportdir eq "";
540 $exportdir =~ s/[\\\/]+/\//g;
541 $exportdir =~ s/\/$//;
542
543 # load all the plugins
544 $pluginfo = &plugin::load_plugins ($plugins, $verbosity, $out, $faillog, \@global_opts);
545
546 if (scalar(@$pluginfo) == 0) {
547 &gsprintf($out, "{import.no_plugins_loaded}\n");
548 die "\n";
[8879]549 }
[9233]550
551 # remove the old contents of the export directory if needed
552 if ($removeold && -e $exportdir) {
553 &gsprintf($out, "{export.removing_export}\n");
554 &util::rm_r ($exportdir);
[8879]555 }
[9233]556
557 # read the export information file
[13169]558
559 # Export to DSpace Archive format or METs format
560 # If saveas=DSpace, a "contents" file will be created, otherwise "export.inf"
[9233]561
[13169]562 # the plugouts should be doing this!!
563 if ($saveas eq "DSpace"){
564 $export_info_filename = &util::filename_cat ($exportdir, "contents");
[14935]565 } elsif ($saveas =~ m/^.*METS$/ || $saveas eq "GA" || $saveas eq "MARC" ) {
[13169]566 $export_info_filename = &util::filename_cat ($exportdir, "export.inf");
567 }
568
569 $export_info = new arcinfo();
570 $export_info -> load_info ($export_info_filename);
571
[14733]572 my ($plugout);
573 if (defined $collectcfg->{'plugout'}) {
574 $plugout = $collectcfg->{'plugout'};
575 }
576 else{
[14935]577 if ($saveas !~ /^(GA|.*METS|DSpace|MARCXML)$/) {
[14733]578 push @$plugout,"GAPlugout";
[9233]579 }
[14733]580 else{
581 push @$plugout,$saveas."Plugout";
582 }
[8879]583 }
[14733]584
585 my $plugout_name = $plugout->[0];
[9233]586
[14733]587 push @$plugout,("-output_info",$export_info) if (defined $export_info);
588 push @$plugout,("-verbosity",$verbosity) if (defined $verbosity);
589 push @$plugout,("-debug") if ($debug);
590 push @$plugout,("-gzip_output",$gzip) if (defined $gzip);
591 push @$plugout,("-group_size",$groupsize) if (defined $groupsize);
592 push @$plugout,("-output_handle",$out) if (defined $out);
593 push @$plugout,("-xslt_file",$xsltfile) if (defined $xsltfile);
[14935]594 push @$plugout,("-group") if ($group_marc && $plugout_name =~ m/^MARCXMLPlugout$/);
595 push @$plugout,("-mapping_file",$mapping_file) if (defined $mapping_file && $plugout_name =~ m/^MARCXMLPlugout$/);
596 push @$plugout,("-xslt_mets",$xslt_mets) if (defined $xslt_mets && $plugout_name =~ m/^.*METSPlugout$/);
597 push @$plugout,("-xslt_txt",$xslt_txt) if (defined $xslt_txt && $plugout_name =~ m/^.*METSPlugout$/);
598 push @$plugout,("-fedora_namespace",$fedora_namespace) if (defined $fedora_namespace && $plugout_name eq "FedoraMETSPlugout");
599
[14733]600 $processor = &plugout::load_plugout($plugout);
[13169]601
602 $processor->setoutputdir ($exportdir);
603
604 $processor->set_sortmeta ($sortmeta) if defined $sortmeta;
605 $processor->set_OIDtype ($OIDtype, $OIDmetadata);
606
[9233]607 &plugin::begin($pluginfo, $importdir, $processor, $maxdocs);
608
609 # process the import directory
[9854]610 &plugin::read ($pluginfo, $importdir, "", {}, $processor, $maxdocs,0, $gli);
[14935]611
612 if ($saveas eq "FedoraMETS")
613 {
614 # create collection "doc obj" for Fedora that contains
615 # collection-level metadata
616
617 my $doc_obj = new doc($configfilename,"nonindexed_doc");
618 $doc_obj->set_OID("collection");
619
620 my $col_name = undef;
621 my $col_meta = $collectcfg->{'collectionmeta'};
622 if (defined $col_meta)
623 {
624 store_collectionmeta($col_meta,"collectionname",$doc_obj);
625 store_collectionmeta($col_meta,"collectioextra",$doc_obj);
626
627 }
628
629 $processor->process($doc_obj);
630 }
[9233]631
632 &plugin::end($pluginfo, $processor);
[10162]633
634 &plugin::deinit($pluginfo, $processor);
[9233]635
636 # write out the export information file
[13169]637 $processor->close_file_output() if $groupsize > 1;
638 $processor->close_group_output() if $processor->is_group();
[14935]639 if ($saveas =~ m/^.*METS$/) {
[13169]640 $export_info->save_info($export_info_filename);
[8879]641 }
[9233]642
[9951]643 # write out export stats
644 my $close_stats = 0;
645 if ($statsfile !~ /^(STDERR|STDOUT)$/i) {
646 if (open (STATS, ">$statsfile")) {
647 $statsfile = 'import::STATS';
648 $close_stats = 1;
649 } else {
650 &gsprintf($out, "{import.cannot_open_stats_file}", $statsfile);
651 &gsprintf($out, "{import.stats_backup}\n");
652 $statsfile = 'STDERR';
653 }
654 }
655
656 &gsprintf($out, "\n");
657 &gsprintf($out, "*********************************************\n");
658
659 &plugin::write_stats($pluginfo, $statsfile, $faillogname, $gli);
660 if ($close_stats) {
661 close STATS;
662 }
663
664 &gsprintf($out, "*********************************************\n");
665
666 close OUT if $close_out;
667
[9233]668 close FAILLOG;
669 };
[8879]670
[9951]671 if ($@) {
672 print STDERR $@;
673 }
674
[9233]675## $ENV{'GSDLCOLLECTION'} = undef;
676 $importdir = "";
[9235]677 $removeold = 0 if ($explicit_exportdir);
[9233]678
[10340]679 } # while processing ARGV
[9233]680
[8879]681 &gsprintf($out, "\n");
682 &gsprintf($out, "*********************************************\n");
[9951]683 &gsprintf($out, "* {export.complete}\n");
684 &gsprintf($out, "*********************************************\n");
[8879]685
686}
Note: See TracBrowser for help on using the repository browser.