source: gsdl/trunk/perllib/colcfg.pm@ 15728

Last change on this file since 15728 was 15728, checked in by mdewsnip, 16 years ago

(Adding new DB support) Now writes the infodbtype field to the build.cfg file so the collection server knows what type of dbclass to use with the collection.

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 7.1 KB
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|/ .
83 q/groupsize|maxdocs|debug|mode|saveas|/ .
84 q/sortmeta|removesuffix|removeprefix|create_images|/ .
85 q/maxnumeric|separate_cjk|languagemetadata|/ .
86 q/no_strip_html|index|sections_index_document_metadata)$/,
87 q/(maintainer|languages|indexsubcollections|/ .
88 q/indexes|indexoptions|dontbuild|dontgdbm|mirror|levels|plugout|/ .
89 q/searchtype|searchtypes)$/,
90 q/^(subcollection|format)$/,
91 q/^(acquire|plugin|classify)$/,
92 q/^(collectionmeta)$/);
93}
94sub read_collection_cfg_xml {
95 my ($filename) = @_;
96
97 return &cfgread4gs3::read_cfg_file ($filename);
98}
99sub write_collection_cfg_xml {
100
101}
102sub write_build_cfg_xml {
103 my ($buildoutfile, $buildcfg, $collectcfg, $disable_OAI) = @_;
104
105 return &cfgread4gs3::write_cfg_file ($buildoutfile, $buildcfg, $collectcfg, $disable_OAI);
106}
107
108sub write_collect_cfg {
109 my ($filename, $data) = @_;
110
111 &cfgread::write_cfg_file($filename, $data,
112 q/^(infodbtype|creator|public|defaultindex|importdir|/ .
113 q/archivedir|cachedir|builddir|removeold|/ .
114 q/textcompress|buildtype|no_text|keepold|gzip|/ .
115 q/verbosity|remove_empty_classifications|OIDtype|/.
116 q/groupsize|maxdocs|debug|mode|saveas|/ .
117 q/sortmeta|removesuffix|removeprefix|create_images|/ .
118 q/maxnumeric|separate_cjk|language_metadata/ .
119 q/no_strip_html|index|sections_index_document_metadata)$/,
120 q/^(maintainer|languages|indexsubcollections|/ .
121 q/indexes|indexoptions|dontbuild|dontgdbm|mirror|levels|/.
122 q/searchtype|searchtypes)$/,
123 q/^(subcollection|format)$/,
124 q/^(acquire|plugin|classify)$/,
125 q/^(collectionmeta)$/);
126}
127
128
129# the build configuration file data is stored in the form
130#
131# {'infodbtype'}->string
132# {'builddate'}->string
133# {'buildtype'}->string
134# {'metadata'}->array of strings
135# {'languages'}->array of strings
136# {'numdocs'}->string
137# {'numsections'}->string
138# {'numwords'}->string
139# {'numbytes'}->string
140# {'maxnumeric'}->string
141# {'indexfields'}->array of strings
142# {'indexfieldmap'}->array of strings in the form "field->FI"
143# {'indexmap'} -> array of strings
144# {'indexlevels'} -> array of strings
145# {'stemindexes'} -> string (int)
146# {'textlevel'}->string
147# {'levelmap'} -> array of strings in the form "level->shortname"
148sub read_build_cfg {
149 my ($filename) = @_;
150
151 return &cfgread::read_cfg_file ($filename,
152 q/^(infodbtype|builddate|buildtype|numdocs|numsections|numwords|numbytes|maxnumeric|textlevel|indexstem|stemindexes)$/,
153 q/^(indexmap|subcollectionmap|languagemap|notbuilt|indexfields|indexfieldmap|indexlevels|levelmap)$/);
154
155}
156
157sub write_build_cfg {
158 my ($filename, $data) = @_;
159
160 &cfgread::write_cfg_file($filename, $data,
161 q/^(infodbtype|builddate|buildtype|numdocs|numsections|numwords|numbytes|maxnumeric|textlevel|indexstem|stemindexes)$/,
162 q/^(indexmap|subcollectionmap|languagemap|notbuilt|indexfields|indexfieldmap|indexlevels|levelmap)$/);
163}
164
165sub get_collect_cfg_name {
166 my ($out) = @_;
167
168 # First check if there's a
169 # gsdl/collect/COLLECTION/custom/COLLECTION/etc/custom.cfg file. This
170 # customization was added for DLC by Stefan, 30/6/2007.
171 my $configfilename = &util::filename_cat ($ENV{'GSDLCOLLECTDIR'}, "custom", $ENV{'GSDLCOLLECTION'}, "etc", "custom.cfg");
172
173 if (-e $configfilename) {
174 return ($configfilename, "gs2");
175 }
176
177 # Now check if there is a collect.cfg file in the usual place, i.e. it is gs2.
178 $configfilename = &util::filename_cat ($ENV{'GSDLCOLLECTDIR'}, "etc", "collect.cfg");
179 if (-e $configfilename) {
180 return ($configfilename, "gs2");
181 }
182
183 # If we get to here we check if there is a collectionConfig.xml file,
184 # i.e. it is gs3.
185 $configfilename = &util::filename_cat ($ENV{'GSDLCOLLECTDIR'}, "etc", "collectionConfig.xml");
186 if (-e $configfilename) {
187 return ($configfilename, "gs3");
188 }
189
190 # Error. No collection configuration file.
191 (&gsprintf($out, "{common.cannot_find_cfg_file}\n", $configfilename) && die);
192}
193
194
195sub use_collection {
196 my ($site, $collection, $collectdir) = @_;
197
198 if ((defined $site) && ($site ne ""))
199 {
200 return &util::use_site_collection($site, $collection, $collectdir);
201 }
202 else
203 {
204 return &util::use_collection($collection, $collectdir);
205 }
206}
207
208
2091;
210
211
Note: See TracBrowser for help on using the repository browser.