source: gsdl/trunk/bin/script/import.pl@ 18440

Last change on this file since 18440 was 18440, checked in by davidb, 12 years ago

Modifications for incremental building to support files that need to be deleted

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 21.6 KB
Line 
1#!/usr/bin/perl -w
2
3###########################################################################
4#
5# import.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 import a number of files into a particular collection
30
31package import;
32
33BEGIN {
34 die "GSDLHOME not set\n" unless defined $ENV{'GSDLHOME'};
35 die "GSDLOS not set\n" unless defined $ENV{'GSDLOS'};
36 unshift (@INC, "$ENV{'GSDLHOME'}/perllib");
37 unshift (@INC, "$ENV{'GSDLHOME'}/perllib/cpan");
38 unshift (@INC, "$ENV{'GSDLHOME'}/perllib/plugins");
39 unshift (@INC, "$ENV{'GSDLHOME'}/perllib/plugouts");
40 unshift (@INC, "$ENV{'GSDLHOME'}/perllib/classify");
41
42 if (defined $ENV{'GSDLEXTS'}) {
43 my @extensions = split(/:/,$ENV{'GSDLEXTS'});
44 foreach my $e (@extensions) {
45 my $ext_prefix = "$ENV{'GSDLHOME'}/ext/$e";
46
47 unshift (@INC, "$ext_prefix/perllib");
48 unshift (@INC, "$ext_prefix/perllib/cpan");
49 unshift (@INC, "$ext_prefix/perllib/plugins");
50 unshift (@INC, "$ext_prefix/perllib/plugouts");
51 unshift (@INC, "$ext_prefix/perllib/classify");
52 }
53 }
54}
55
56use strict;
57no strict 'refs'; # allow filehandles to be variables and vice versa
58no strict 'subs'; # allow barewords (eg STDERR) as function arguments
59
60use arcinfo;
61use colcfg;
62use plugin;
63use plugout;
64use manifest;
65use util;
66use scriptutil;
67use FileHandle;
68use gsprintf 'gsprintf';
69use printusage;
70use parse2;
71
72
73
74my $oidtype_list =
75 [ { 'name' => "hash",
76 'desc' => "{import.OIDtype.hash}" },
77 { 'name' => "assigned",
78 'desc' => "{import.OIDtype.assigned}" },
79 { 'name' => "incremental",
80 'desc' => "{import.OIDtype.incremental}" },
81 { 'name' => "dirname",
82 'desc' => "{import.OIDtype.dirname}" } ];
83
84
85# used to control output file format
86my $saveas_list =
87 [ { 'name' => "GreenstoneXML",
88 'desc' => "{export.saveas.GreenstoneXML}"},
89 { 'name' => "GreenstoneMETS",
90 'desc' => "{export.saveas.GreenstoneMETS}"},
91 ];
92
93
94# Possible attributes for each argument
95# name: The name of the argument
96# desc: A description (or more likely a reference to a description) for this argument
97# type: The type of control used to represent the argument. Options include: string, int, flag, regexp, metadata, language, enum etc
98# reqd: Is this argument required?
99# hiddengli: Is this argument hidden in GLI?
100# modegli: The lowest detail mode this argument is visible at in GLI
101
102my $saveas_argument
103 = { 'name' => "saveas",
104 'desc' => "{import.saveas}",
105 'type' => "enum",
106 'list' => $saveas_list,
107 'deft' => "GreenstoneXML",
108 'reqd' => "no",
109 'modegli' => "3" };
110
111
112my $arguments =
113 [
114 $saveas_argument,
115 { 'name' => "archivedir",
116 'desc' => "{import.archivedir}",
117 'type' => "string",
118 'reqd' => "no",
119 'hiddengli' => "yes" },
120 { 'name' => "importdir",
121 'desc' => "{import.importdir}",
122 'type' => "string",
123 'reqd' => "no",
124 'hiddengli' => "yes" },
125 { 'name' => "collectdir",
126 'desc' => "{import.collectdir}",
127 'type' => "string",
128 # parsearg left "" as default
129 #'deft' => &util::filename_cat ($ENV{'GSDLHOME'}, "collect"),
130 'deft' => "",
131 'reqd' => "no",
132 'hiddengli' => "yes" },
133 { 'name' => "site",
134 'desc' => "{import.site}",
135 'type' => "string",
136 'deft' => "",
137 'reqd' => "no",
138 'hiddengli' => "yes" },
139 { 'name' => "manifest",
140 'desc' => "{import.manifest}",
141 'type' => "string",
142 'deft' => "",
143 'reqd' => "no",
144 'hiddengli' => "yes" },
145 { 'name' => "debug",
146 'desc' => "{import.debug}",
147 'type' => "flag",
148 'reqd' => "no",
149 'hiddengli' => "yes" },
150 { 'name' => "faillog",
151 'desc' => "{import.faillog}",
152 'type' => "string",
153 # parsearg left "" as default
154 #'deft' => &util::filename_cat("<collectdir>", "colname", "etc", "fail.log"),
155 'deft' => "",
156 'reqd' => "no",
157 'modegli' => "4" },
158 { 'name' => "incremental",
159 'desc' => "{import.incremental}",
160 'type' => "flag",
161 'hiddengli' => "yes" },
162 { 'name' => "keepold",
163 'desc' => "{import.keepold}",
164 'type' => "flag",
165 'reqd' => "no",
166 'hiddengli' => "yes" },
167 { 'name' => "removeold",
168 'desc' => "{import.removeold}",
169 'type' => "flag",
170 'reqd' => "no",
171 'hiddengli' => "yes" },
172 { 'name' => "language",
173 'desc' => "{scripts.language}",
174 'type' => "string",
175 'reqd' => "no",
176 'hiddengli' => "yes" },
177 { 'name' => "maxdocs",
178 'desc' => "{import.maxdocs}",
179 'type' => "int",
180 'reqd' => "no",
181 # parsearg left "" as default
182 #'deft' => "-1",
183 'range' => "1,",
184 'modegli' => "1" },
185 # don't set the default to hash - want to allow this to come from
186 # entry in collect.cfg but want to override it here
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' => "2" },
195 { 'name' => "OIDmetadata",
196 'desc' => "{import.OIDmetadata}",
197 'type' => "metadata",
198 'deft' => "dc.Identifier",
199 'reqd' => "no",
200 'modegli' => "2" },
201 { 'name' => "out",
202 'desc' => "{import.out}",
203 'type' => "string",
204 'deft' => "STDERR",
205 'reqd' => "no",
206 'hiddengli' => "yes" },
207 { 'name' => "sortmeta",
208 'desc' => "{import.sortmeta}",
209 'type' => "metadata",
210 'reqd' => "no",
211 'modegli' => "3" },
212 { 'name' => "reversesort",
213 'desc' => "{import.reversesort}",
214 'type' => "flag",
215 'reqd' => "no",
216 'modegli' => "3" },
217 { 'name' => "removeprefix",
218 'desc' => "{BasClas.removeprefix}",
219 'type' => "regexp",
220 'deft' => "",
221 'reqd' => "no",
222 'modegli' => "3" },
223 { 'name' => "removesuffix",
224 'desc' => "{BasClas.removesuffix}",
225 'type' => "regexp",
226 'deft' => "",
227 'reqd' => "no",
228 'modegli' => "3" },
229 { 'name' => "groupsize",
230 'desc' => "{import.groupsize}",
231 'type' => "int",
232 'deft' => "1",
233 'reqd' => "no",
234 'modegli' => "3" },
235 { 'name' => "gzip",
236 'desc' => "{import.gzip}",
237 'type' => "flag",
238 'reqd' => "no",
239 'modegli' => "4" },
240 { 'name' => "statsfile",
241 'desc' => "{import.statsfile}",
242 'type' => "string",
243 'deft' => "STDERR",
244 'reqd' => "no",
245 'hiddengli' => "yes" },
246 { 'name' => "verbosity",
247 'desc' => "{import.verbosity}",
248 'type' => "int",
249 'range' => "0,",
250 # parsearg left "" as default
251 #'deft' => "2",
252 'reqd' => "no",
253 'modegli' => "4" },
254 { 'name' => "gli",
255 'desc' => "{scripts.gli}",
256 'type' => "flag",
257 'reqd' => "no",
258 'hiddengli' => "yes" },
259 { 'name' => "xml",
260 'desc' => "{scripts.xml}",
261 'type' => "flag",
262 'reqd' => "no",
263 'hiddengli' => "yes" }];
264
265my $options = { 'name' => "import.pl",
266 'desc' => "{import.desc}",
267 'args' => $arguments };
268
269
270&main();
271
272sub main {
273 # params
274 my ($language, $verbosity, $debug,
275 $collectdir, $importdir, $archivedir, $site, $manifest,
276 $incremental, $keepold, $removeold,
277 $saveas,
278 $OIDtype, $OIDmetadata,
279 $maxdocs, $statsfile,
280 $out, $faillog, $gli,
281 $gzip, $groupsize,
282 $sortmeta, $reversesort, $removeprefix, $removesuffix
283 );
284
285 my $xml = 0;
286
287 # other vars
288 my ($configfilename, $collection, $collectcfg,
289 $arcinfo_doc_filename, $arcinfo_src_filename, $archive_info,
290 $gs_mode,
291 $processor, $pluginfo);
292
293 my $service = "import";
294
295 my $hashParsingResult = {};
296 # general options available to all plugins
297 my $intArgLeftinAfterParsing = parse2::parse(\@ARGV,$arguments,$hashParsingResult,"allow_extra_options");
298 # Parse returns -1 if something has gone wrong
299 if ($intArgLeftinAfterParsing == -1)
300 {
301 &PrintUsage::print_txt_usage($options, "{import.params}");
302 die "\n";
303 }
304
305 foreach my $strVariable (keys %$hashParsingResult)
306 {
307 eval "\$$strVariable = \$hashParsingResult->{\"\$strVariable\"}";
308 }
309
310 # If $language has been specified, load the appropriate resource bundle
311 # (Otherwise, the default resource bundle will be loaded automatically)
312 if ($language && $language =~ /\S/) {
313 &gsprintf::load_language_specific_resource_bundle($language);
314 }
315
316 if ($xml) {
317 &PrintUsage::print_xml_usage($options);
318 print "\n";
319 return;
320 }
321
322 if ($gli) { # the gli wants strings to be in UTF-8
323 &gsprintf::output_strings_in_UTF8;
324 }
325
326 # now check that we had exactly one leftover arg, which should be
327 # the collection name. We don't want to do this earlier, cos
328 # -xml arg doesn't need a collection name
329 # Or if the user specified -h, then we output the usage also
330 if ($intArgLeftinAfterParsing != 1 || (@ARGV && $ARGV[0] =~ /^\-+h/))
331 {
332 &PrintUsage::print_txt_usage($options, "{import.params}");
333 die "\n";
334 }
335
336 my $close_out = 0;
337 if ($out !~ /^(STDERR|STDOUT)$/i) {
338 open (OUT, ">$out") ||
339 (&gsprintf(STDERR, "{common.cannot_open_output_file}: $!\n", $out) && die);
340 $out = 'import::OUT';
341 $close_out = 1;
342 }
343 $out->autoflush(1);
344
345 # get and check the collection name
346 if (($collection = &colcfg::use_collection($site, @ARGV, $collectdir)) eq "") {
347 &PrintUsage::print_txt_usage($options, "{import.params}");
348 die "\n";
349 }
350
351 # add collection's perllib dir into include path in
352 # case we have collection specific modules
353 unshift (@INC, "$ENV{'GSDLCOLLECTDIR'}/perllib");
354
355 # check that we can open the faillog
356 if ($faillog eq "") {
357 $faillog = &util::filename_cat($ENV{'GSDLCOLLECTDIR'}, "etc", "fail.log");
358 }
359 open (FAILLOG, ">$faillog") ||
360 (&gsprintf(STDERR, "{import.cannot_open_fail_log}\n", $faillog) && die);
361
362
363 my $faillogname = $faillog;
364 $faillog = 'import::FAILLOG';
365 $faillog->autoflush(1);
366
367 # Read in the collection configuration file.
368 ($configfilename, $gs_mode) = &colcfg::get_collect_cfg_name($out);
369
370 if ($gs_mode eq "gs2") {
371 $collectcfg = &colcfg::read_collect_cfg ($configfilename);
372 } elsif ($gs_mode eq "gs3") {
373 $collectcfg = &colcfg::read_collection_cfg_xml ($configfilename);
374 }
375
376 if (defined $collectcfg->{'importdir'} && $importdir eq "") {
377 $importdir = $collectcfg->{'importdir'};
378 }
379 if (defined $collectcfg->{'archivedir'} && $archivedir eq "") {
380 $archivedir = $collectcfg->{'archivedir'};
381 }
382 # fill in the default import and archives directories if none
383 # were supplied, turn all \ into / and remove trailing /
384 $importdir = &util::filename_cat ($ENV{'GSDLCOLLECTDIR'}, "import") if $importdir eq "";
385 $importdir =~ s/[\\\/]+/\//g;
386 $importdir =~ s/\/$//;
387 if (!-e $importdir) {
388 &gsprintf($out, "{import.no_import_dir}\n\n", $importdir);
389 die "\n";
390 }
391
392 $archivedir = &util::filename_cat ($ENV{'GSDLCOLLECTDIR'}, "archives") if $archivedir eq "";
393 $archivedir =~ s/[\\\/]+/\//g;
394 $archivedir =~ s/\/$//;
395
396 my $plugins = [];
397 if (defined $collectcfg->{'plugin'}) {
398 $plugins = $collectcfg->{'plugin'};
399 }
400 #some global options for the plugins
401 my @global_opts = ();
402
403 if ($verbosity !~ /\d+/) {
404 if (defined $collectcfg->{'verbosity'} && $collectcfg->{'verbosity'} =~ /\d+/) {
405 $verbosity = $collectcfg->{'verbosity'};
406 } else {
407 $verbosity = 2; # the default
408 }
409 }
410 if (defined $collectcfg->{'manifest'} && $manifest eq "") {
411 $manifest = $collectcfg->{'manifest'};
412 }
413
414 if (defined $collectcfg->{'gzip'} && !$gzip) {
415 if ($collectcfg->{'gzip'} =~ /^true$/i) {
416 $gzip = 1;
417 }
418 }
419
420 if ($maxdocs !~ /\-?\d+/) {
421 if (defined $collectcfg->{'maxdocs'} && $collectcfg->{'maxdocs'} =~ /\-?\d+/) {
422 $maxdocs = $collectcfg->{'maxdocs'};
423 } else {
424 $maxdocs = -1; # the default
425 }
426 }
427 if ($groupsize == 1) {
428 if (defined $collectcfg->{'groupsize'} && $collectcfg->{'groupsize'} =~ /\d+/) {
429 $groupsize = $collectcfg->{'groupsize'};
430 }
431 }
432
433 if (!defined $OIDtype || ($OIDtype !~ /^(hash|incremental|assigned|dirname)$/ )) {
434 if (defined $collectcfg->{'OIDtype'} && $collectcfg->{'OIDtype'} =~ /^(hash|incremental|assigned|dirname)$/) {
435 $OIDtype = $collectcfg->{'OIDtype'};
436 } else {
437 $OIDtype = "hash"; # the default
438 }
439 }
440
441 if (defined $collectcfg->{'sortmeta'} && (!defined $sortmeta || $sortmeta eq "")) {
442 $sortmeta = $collectcfg->{'sortmeta'};
443 }
444 # sortmeta cannot be used with group size
445 $sortmeta = undef unless defined $sortmeta && $sortmeta =~ /\S/;
446 if (defined $sortmeta && $groupsize > 1) {
447 &gsprintf($out, "{import.cannot_sort}\n\n");
448 $sortmeta = undef;
449 }
450
451 if (defined $sortmeta) {
452 if (defined $collectcfg->{'reversesort'} && $collectcfg->{'reversesort'} =~ /^true$/i) {
453 $reversesort = 1;
454 }
455 } else {
456 # reversesort only valid with sortmeta
457 $reversesort = 0;
458 }
459 if (defined $collectcfg->{'removeprefix'} && $removeprefix eq "") {
460 $removeprefix = $collectcfg->{'removeprefix'};
461 }
462
463 if (defined $collectcfg->{'removesuffix'} && $removesuffix eq "") {
464 $removesuffix = $collectcfg->{'removesuffix'};
465 }
466 if (defined $collectcfg->{'debug'} && $collectcfg->{'debug'} =~ /^true$/i) {
467 $debug = 1;
468 }
469 if (defined $collectcfg->{'gli'} && $collectcfg->{'gli'} =~ /^true$/i) {
470 $gli = 1;
471 }
472 $gli = 0 unless defined $gli;
473
474 # check keepold and removeold
475 ($removeold, $keepold, $incremental) = &scriptutil::check_removeold_and_keepold($removeold, $keepold, $incremental, "archives", $collectcfg);
476
477
478 print STDERR "<Import>\n" if $gli;
479
480 my $manifest_lookup = new manifest();
481 if ($manifest ne "") {
482 my $manifest_filename = $manifest;
483
484 if ($manifest_filename !~ m/^[\\\/]/) {
485 $manifest_filename = &util::filename_cat ($ENV{'GSDLCOLLECTDIR'}, $manifest_filename);
486 }
487
488 $manifest =~ s/[\\\/]+/\//g;
489 $manifest =~ s/\/$//;
490
491 $manifest_lookup->parse($manifest_filename);
492 }
493
494
495 # load all the plugins
496 $pluginfo = &plugin::load_plugins ($plugins, $verbosity, $out, $faillog, \@global_opts, $incremental);
497 if (scalar(@$pluginfo) == 0) {
498 &gsprintf($out, "{import.no_plugins_loaded}\n");
499 die "\n";
500 }
501
502 # remove the old contents of the archives directory (and tmp directory) if needed
503 if ($removeold) {
504 if (-e $archivedir) {
505 &gsprintf($out, "{import.removing_archives}\n");
506 &util::rm_r ($archivedir);
507 }
508 my $tmpdir = &util::filename_cat ($ENV{'GSDLCOLLECTDIR'}, "tmp");
509 $tmpdir =~ s/[\\\/]+/\//g;
510 $tmpdir =~ s/\/$//;
511 if (-e $tmpdir) {
512 &gsprintf($out, "{import.removing_tmpdir}\n");
513 &util::rm_r ($tmpdir);
514 }
515 }
516 # create the archives dir if needed
517 &util::mk_all_dir($archivedir);
518
519 # read the archive information file
520## $arcinfo_doc_filename = &util::filename_cat ($archivedir, "archives.inf");
521
522 my $db_ext = &util::is_little_endian() ? ".ldb" : ".bdb";
523 my $doc_db = "archiveinf-doc$db_ext";
524 my $src_db = "archiveinf-src$db_ext";
525 $arcinfo_doc_filename = &util::filename_cat ($archivedir, $doc_db);
526 $arcinfo_src_filename = &util::filename_cat ($archivedir, $src_db);
527
528 $archive_info = new arcinfo ();
529 $archive_info->load_info ($arcinfo_doc_filename);
530 if ($reversesort) {
531 $archive_info->reverse_sort();
532 }
533
534 if ($manifest eq "") {
535 # Load in list of files in import folder from last import (if present)
536 $archive_info->load_import_filelist ($arcinfo_src_filename);
537 }
538
539 ####Use Plugout####
540 my ($plugout);
541 if (defined $collectcfg->{'plugout'} && $collectcfg->{'plugout'} =~ /^(GreenstoneXML|GreenstoneMETS)Plugout/) {
542 $plugout = $collectcfg->{'plugout'};
543 }
544 else{
545 if ($saveas !~ /^(GreenstoneXML|GreenstoneMETS)$/) {
546 push @$plugout,"GreenstoneXMLPlugout";
547 }
548 else{
549 push @$plugout,$saveas."Plugout";
550 }
551 }
552
553 push @$plugout,("-output_info",$archive_info) if (defined $archive_info);
554 push @$plugout,("-verbosity",$verbosity) if (defined $verbosity);
555 push @$plugout,("-gzip_output") if ($gzip);
556 push @$plugout,("-group_size",$groupsize) if (defined $groupsize);
557 push @$plugout,("-output_handle",$out) if (defined $out);
558 push @$plugout,("-debug") if ($debug);
559
560 $processor = &plugout::load_plugout($plugout);
561 $processor->setoutputdir ($archivedir);
562 $processor->set_sortmeta ($sortmeta, $removeprefix, $removesuffix) if defined $sortmeta;
563 $processor->set_OIDtype ($OIDtype, $OIDmetadata);
564
565 &plugin::begin($pluginfo, $importdir, $processor, $maxdocs, $gli);
566
567 if ($manifest eq "") {
568 # process the import directory
569 my $block_hash = {};
570 my $metadata = {};
571 # gobal blocking pass may set up some metadata
572 &plugin::file_block_read($pluginfo, $importdir, "", $block_hash, $metadata, $gli);
573 # Can now work out which files were deleted
574
575 # First convert all files to absolute form
576 # This is to support the situation where the import folder is not
577 # the default
578
579 my $prev_all_files = $archive_info->{'import_filelist'};
580 foreach my $prev_file (keys %$prev_all_files) {
581
582 if (!&util::filename_is_absolute($prev_file)) {
583 my $full_prev_file = &util::filename_cat($ENV{'GSDLCOLLECTDIR'},$prev_file);
584 delete $prev_all_files->{$prev_file};
585 $prev_all_files->{$full_prev_file} = 1;
586 }
587 }
588
589 # Figure out which are the new files, existing files and so
590 # by implication the files from the previous import that are not
591 # there any more => mark them for deletion
592 foreach my $curr_file (keys %{$block_hash->{'all_files'}}) {
593
594 my $full_curr_file = $curr_file;
595
596 if (!&util::filename_is_absolute($curr_file)) {
597 # add in import dir to make absolute
598 $full_curr_file = &util::filename_cat($importdir,$curr_file);
599 }
600
601## print STDERR "**** Checking $curr_file\n";
602
603 # figure of if new file or not
604 if (defined $prev_all_files->{$full_curr_file}) {
605 # had it before
606 $block_hash->{'existing_files'}->{$curr_file} = 1;
607 # Now remove it, so by end of loop only the files
608 # that need deleting are left
609
610 delete $prev_all_files->{$full_curr_file}
611 }
612 else {
613 $block_hash->{'new_files'}->{$curr_file} = 1;
614 }
615
616 delete $block_hash->{'all_files'}->{$curr_file};
617 }
618
619 print STDERR "Delete files:\n ";
620
621 my @delete_files = keys %$prev_all_files;
622 print STDERR join("\n ",@delete_files), "\n";
623
624 &plugin::read ($pluginfo, $importdir, "", $block_hash, $metadata, $processor, $maxdocs, 0, $gli);
625 }
626 else
627 {
628 # process any files marked for importing
629 foreach my $file (keys %{$manifest_lookup->{'index'}}) {
630 &plugin::read ($pluginfo, $importdir, $file, {}, {}, $processor, $maxdocs, 0, $gli);
631 }
632
633 # record files marked for deletion in arcinfo
634 foreach my $file (keys %{$manifest_lookup->{'delete'}}) {
635 # use 'archiveinf-src' GDBM file to look up all the OIDs
636 # this file is used in (note in most cases, it's just one OID)
637
638 # An improvement would be to have the record read
639 # into a hash array
640 # gdbmRecordToHash
641
642 my $gdbm_val
643 = &GDBMUtil::gdbmDatabaseGet($arcinfo_src_filename,$file);
644
645 my @oids = ($gdbm_val =~ m/^<oid>(.*)$/gm);
646 foreach my $oid (@oids) {
647
648 # find out if it's an assoc file or main doc
649
650 # archiveinf-doc, lookup $oid
651 # if "doc-file"
652 # mark it for deletion
653
654 # else (assoc file)
655 # mark all for re-indexing
656
657 # Now delete file
658 }
659
660 # $archive_info->add_info($OID,$doc_xml_file,"D");
661 }
662 }
663
664 &plugin::end($pluginfo, $processor);
665
666 &plugin::deinit($pluginfo, $processor);
667
668 # write out the archive information file
669 $processor->close_file_output() if $groupsize > 1;
670 $processor->close_group_output() if $processor->is_group();
671
672# The following 'if' statement is in the export.pl version of the script,
673# The reason for the 'if' statement is now given in export.pl
674# Unclear at this point if the same should be done here
675## if (($saveas =~ m/^.*METS$/) || ($saveas eq "MARC")) {
676 # Not all export types need this (e.g. DSpace)
677
678 # should we still do this in debug mode??
679
680 # for backwards compatability with archvies.inf file
681 if ($arcinfo_doc_filename =~ m/\.inf$/) {
682 $archive_info->save_info($arcinfo_doc_filename);
683 }
684
685## }
686
687 # write out import stats
688 my $close_stats = 0;
689 if ($statsfile !~ /^(STDERR|STDOUT)$/i) {
690 if (open (STATS, ">$statsfile")) {
691 $statsfile = 'import::STATS';
692 $close_stats = 1;
693 } else {
694 &gsprintf($out, "{import.cannot_open_stats_file}", $statsfile);
695 &gsprintf($out, "{import.stats_backup}\n");
696 $statsfile = 'STDERR';
697 }
698 }
699
700 &gsprintf($out, "\n");
701 &gsprintf($out, "*********************************************\n");
702 &gsprintf($out, "{import.complete}\n");
703 &gsprintf($out, "*********************************************\n");
704
705 &plugin::write_stats($pluginfo, $statsfile, $faillogname, $gli);
706 if ($close_stats) {
707 close STATS;
708 }
709
710 close OUT if $close_out;
711 close FAILLOG;
712}
Note: See TracBrowser for help on using the repository browser.