root/gsdl/trunk/perllib/colcfg.pm @ 18528

Revision 18528, 7.1 KB (checked in by davidb, 11 years ago)

OIDmetadata wasn't supported in collect.cfg, but OIDtype was. Now rectified. Also introduced OIDcount as a file saved in the archives folder to help doc.pm use the correct value when working incrementally

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
Line 
1###########################################################################
2#
3# colcfg.pm --
4# A component of the Greenstone digital library software
5# from the New Zealand Digital Library Project at the
6# University of Waikato, New Zealand.
7#
8# Copyright (C) 1999 New Zealand Digital Library Project
9#
10# This program is free software; you can redistribute it and/or modify
11# it under the terms of the GNU General Public License as published by
12# the Free Software Foundation; either version 2 of the License, or
13# (at your option) any later version.
14#
15# This program is distributed in the hope that it will be useful,
16# but WITHOUT ANY WARRANTY; without even the implied warranty of
17# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18# GNU General Public License for more details.
19#
20# You should have received a copy of the GNU General Public License
21# along with this program; if not, write to the Free Software
22# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23#
24###########################################################################
25
26# reads in a collection configuration file
27
28package colcfg;
29
30use cfgread;
31use cfgread4gs3;
32use gsprintf 'gsprintf';
33use strict;
34
35# the collection configuration file data is stored in the form
36#
37# {'infodbtype'}->string
38# {'creator'}->string
39# {'public'}->string
40# {'defaultindex'}->string
41# {'importdir'}->string
42# {'archivedir'}->string
43# {'cachedir'}->string
44# {'builddir'}->string
45# {'removeold'}->string
46# {'textcompress'}->string
47# {'buildtype'}->string
48# {'maxnumeric'}->string
49# {'separate_cjk'}->string
50# {'sections_index_document_metadata'}->string (always, unless_section_metadata_exists)
51# {'maintainer'}->array of strings
52# {'languages'}->array of strings
53# {'indexsubcollections'}->array of strings
54# {'indexes'}->array of strings
55# {'indexoptions'}->array of strings (stem, casefold, accentfold)
56# {'dontbuild'}->array of strings
57# {'dontgdbm'}->array of strings
58# {'mirror'}->array of strings
59# {'phind'}->array of strings
60# {'plugout'}->array of strings
61# {'levels'}->array of strings (for mgpp eg Section, Paragraph)
62# {'searchtype'}->array of strings (for mgpp, form or plain)
63
64# {'subcollection'}->hash of key-value pairs
65
66# {'acquire'}->array of arrays of strings
67# {'plugin'}->array of arrays of strings
68# {'classify'}->array of arrays of strings
69
70# {'collectionmeta'}->hash of key->hash of param-value -used
71# for language specification
72#    for example, collectionmeta->collectionname->default->demo
73#                                               ->mi->maori demo
74
75sub read_collect_cfg {
76    my ($filename) = @_;
77
78    return &cfgread::read_cfg_file ($filename,
79                    q/^(infodbtype|creator|public|defaultindex|importdir|/ .
80                    q/archivedir|cachedir|builddir|removeold|/ .
81                    q/textcompress|buildtype|no_text|keepold|gzip|/ .
82                    q/verbosity|remove_empty_classifications|OIDtype|OIDmetadata|/ .
83                    q/groupsize|maxdocs|debug|mode|saveas|/ .
84                    q/sortmeta|removesuffix|removeprefix|create_images|/ .
85                    q/maxnumeric|languagemetadata|/ .
86                    q/no_strip_html|index|sections_index_document_metadata|/ .
87                    q/store_metadata_coverage)$/,
88                    q/(maintainer|languages|indexsubcollections|/ .
89                       q/indexes|indexoptions|dontbuild|dontgdbm|mirror|levels|plugout|/ .
90                       q/searchtype|searchtypes)$/,
91                    q/^(subcollection|format)$/,
92                    q/^(acquire|plugin|classify)$/,
93                    q/^(collectionmeta)$/);
94}
95sub read_collection_cfg_xml {
96    my ($filename) = @_;
97
98    return &cfgread4gs3::read_cfg_file ($filename);
99}
100sub write_collection_cfg_xml {
101 
102}
103sub write_build_cfg_xml {
104    my ($buildoutfile, $buildcfg, $collectcfg, $disable_OAI) = @_;
105
106    return &cfgread4gs3::write_cfg_file ($buildoutfile, $buildcfg, $collectcfg, $disable_OAI);
107}
108
109sub write_collect_cfg {
110    my ($filename, $data) = @_;
111   
112    &cfgread::write_cfg_file($filename, $data,
113                 q/^(infodbtype|creator|public|defaultindex|importdir|/ .
114                 q/archivedir|cachedir|builddir|removeold|/ .
115                 q/textcompress|buildtype|no_text|keepold|gzip|/ .
116                 q/verbosity|remove_empty_classifications|OIDtype|OIDmetadata|/.
117                 q/groupsize|maxdocs|debug|mode|saveas|/ .
118                 q/sortmeta|removesuffix|removeprefix|create_images|/ .
119                 q/maxnumeric|language_metadata/ .
120                 q/no_strip_html|index|sections_index_document_metadata)$/,
121                 q/^(maintainer|languages|indexsubcollections|/ .
122                 q/indexes|indexoptions|dontbuild|dontgdbm|mirror|levels|/.
123                 q/searchtype|searchtypes)$/,
124                 q/^(subcollection|format)$/,
125                 q/^(acquire|plugin|classify)$/,
126                 q/^(collectionmeta)$/);
127}
128
129
130# the build configuration file data is stored in the form
131#
132# {'infodbtype'}->string
133# {'builddate'}->string
134# {'buildtype'}->string
135# {'metadata'}->array of strings
136# {'languages'}->array of strings
137# {'numdocs'}->string
138# {'numsections'}->string
139# {'numwords'}->string
140# {'numbytes'}->string
141# {'maxnumeric'}->string
142# {'indexfields'}->array of strings
143# {'indexfieldmap'}->array of strings in the form "field->FI"
144# {'indexmap'} -> array of strings
145# {'indexlevels'} -> array of strings
146# {'stemindexes'} -> string (int)
147# {'textlevel'}->string
148# {'levelmap'} -> array of strings in the form "level->shortname"
149sub read_build_cfg {
150    my ($filename) = @_;
151
152    return &cfgread::read_cfg_file ($filename,
153           q/^(infodbtype|builddate|buildtype|numdocs|numsections|numwords|numbytes|maxnumeric|textlevel|indexstem|stemindexes|separate_cjk)$/,
154           q/^(indexmap|subcollectionmap|languagemap|notbuilt|indexfields|indexfieldmap|indexlevels|levelmap)$/);
155                   
156}
157
158sub write_build_cfg {
159    my ($filename, $data) = @_;
160
161    &cfgread::write_cfg_file($filename, $data,
162           q/^(infodbtype|builddate|buildtype|numdocs|numsections|numwords|numbytes|maxnumeric|textlevel|indexstem|stemindexes|separate_cjk)$/,
163           q/^(indexmap|subcollectionmap|languagemap|notbuilt|indexfields|indexfieldmap|indexlevels|levelmap)$/);           
164}
165
166sub get_collect_cfg_name {
167    my ($out) = @_;
168
169    # First check if there's a
170    # gsdl/collect/COLLECTION/custom/COLLECTION/etc/custom.cfg file. This
171    # customization was added for DLC by Stefan, 30/6/2007.
172    my $configfilename = &util::filename_cat ($ENV{'GSDLCOLLECTDIR'}, "custom", $ENV{'GSDLCOLLECTION'}, "etc", "custom.cfg");
173
174    if (-e $configfilename) {
175        return ($configfilename, "gs2");
176    }
177
178    # Now check if there is a collect.cfg file in the usual place, i.e. it is gs2.
179    $configfilename = &util::filename_cat ($ENV{'GSDLCOLLECTDIR'}, "etc", "collect.cfg");
180    if (-e $configfilename) {
181        return ($configfilename, "gs2");
182    }
183
184    # If we get to here we check if there is a collectionConfig.xml file,
185    # i.e. it is gs3.
186    $configfilename = &util::filename_cat ($ENV{'GSDLCOLLECTDIR'}, "etc", "collectionConfig.xml");   
187    if (-e $configfilename) {
188        return ($configfilename, "gs3");
189    }
190
191    # Error. No collection configuration file.
192    (&gsprintf($out, "{common.cannot_find_cfg_file}\n", $configfilename) && die);
193}
194
195
196sub use_collection {
197   my ($site, $collection, $collectdir) = @_;
198
199   if ((defined $site) && ($site ne ""))
200   {
201       return &util::use_site_collection($site, $collection, $collectdir);
202   }
203   else
204   {
205       return &util::use_collection($collection, $collectdir);
206   }
207}
208
209
2101;
211
212
Note: See TracBrowser for help on using the browser.