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

Last change on this file since 9 was 9, checked in by sjboddie, 25 years ago

Changed pathnames from lib to perllib

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 1.8 KB
Line 
1#!/usr/local/bin/perl5 -w
2
3# This program will import a number of files into a particular collection
4
5BEGIN {
6 die "GSDLHOME not set\n" unless defined $ENV{'GSDLHOME'};
7 die "GSDLOS not set\n" unless defined $ENV{'GSDLOS'};
8 unshift (@INC, "$ENV{'GSDLHOME'}/perllib");
9 unshift (@INC, "$ENV{'GSDLHOME'}/perllib/plugins");
10}
11
12use arcinfo;
13use colcfg;
14use plugin;
15use docsave;
16
17
18sub print_usage {
19 print STDERR "\n usage: $0 collection-name\n";
20}
21
22
23&main ();
24
25sub main {
26 # get and check the collection name
27 ($collection) = @ARGV;
28 if (!defined($collection)) {
29 &print_usage();
30 die "\n";
31 }
32
33 if ($collection eq "modelcol") {
34 print STDERR "You can't import documents into modelcol.\n";
35 die "\n";
36 }
37
38 # get the list of plugins for this collection
39 @plugins = ("RecPlug", "HTMLPlug", "TXTPlug");
40 if (-e "$ENV{'GSDLHOME'}/collect/$collection/collect.cfg") {
41 $collectcfg = &colcfg::read_collect_cfg ("$ENV{'GSDLHOME'}/collect/$collection/collect.cfg");
42 if (defined $collectcfg->{'plugins'}) {
43 @plugins = @{$collectcfg->{'plugins'}};
44 }
45 }
46
47
48 # load all the plugins
49 $pluginfo = &plugin::load_plugins ($collection, \@plugins);
50 if (scalar(@$pluginfo) == 0) {
51 print STDERR "No plugins were loaded.\n";
52 die "\n";
53 }
54
55 # read the archive information file
56 $archive_info_filename = "$ENV{'GSDLHOME'}/collect/$collection/archives/archives.inf";
57 $archive_info = new arcinfo ();
58 $archive_info->load_info ($archive_info_filename);
59
60 # create a docsave object to process the documents
61 $processor = new docsave ($collection, $archive_info);
62
63 # process the import directory
64 &plugin::read ($pluginfo, "$ENV{'GSDLHOME'}/collect/$collection/import/",
65 "", {}, $processor);
66
67 # write out the archive information file
68 $archive_info->save_info($archive_info_filename);
69}
Note: See TracBrowser for help on using the repository browser.