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

Last change on this file since 14115 was 14115, checked in by sjboddie, 14 years ago

* empty log message *

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 6.8 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# {'creator'}->string
38# {'public'}->string
39# {'defaultindex'}->string
40# {'importdir'}->string
41# {'archivedir'}->string
42# {'cachedir'}->string
43# {'builddir'}->string
44# {'removeold'}->string
45# {'textcompress'}->string
46# {'buildtype'}->string
47# {'maxnumeric'}->string
48# {'separate_cjk'}->string
49# {'sections_index_document_metadata'}->string (always, unless_section_metadata_exists)
50# {'maintainer'}->array of strings
51# {'languages'}->array of strings
52# {'indexsubcollections'}->array of strings
53# {'indexes'}->array of strings
54# {'indexoptions'}->array of strings (stem, casefold, accentfold)
55# {'dontbuild'}->array of strings
56# {'dontgdbm'}->array of strings
57# {'mirror'}->array of strings
58# {'phind'}->array of strings
59# {'plugout'}->array of strings
60# {'levels'}->array of strings (for mgpp eg Section, Paragraph)
61# {'searchtype'}->array of strings (for mgpp, form or plain)
62
63# {'subcollection'}->hash of key-value pairs
64
65# {'acquire'}->array of arrays of strings
66# {'plugin'}->array of arrays of strings
67# {'classify'}->array of arrays of strings
68
69# {'collectionmeta'}->hash of key->hash of param-value -used
70# for language specification
71# for example, collectionmeta->collectionname->default->demo
72# ->mi->maori demo
73
74sub read_collect_cfg {
75 my ($filename) = @_;
76
77 return &cfgread::read_cfg_file ($filename,
78 q/^(creator|public|defaultindex|importdir|/ .
79 q/archivedir|cachedir|builddir|removeold|/ .
80 q/textcompress|buildtype|no_text|keepold|gzip|/ .
81 q/verbosity|remove_empty_classifications|OIDtype|/ .
82 q/groupsize|maxdocs|debug|mode|saveas|/ .
83 q/sortmeta|removesuffix|removeprefix|create_images|/ .
84 q/maxnumeric|separate_cjk|languagemetadata|/ .
85 q/no_strip_html|index|sections_index_document_metadata)$/,
86 q/(maintainer|languages|indexsubcollections|/ .
87 q/indexes|indexoptions|dontbuild|dontgdbm|mirror|levels|plugout|/ .
88 q/searchtype|searchtypes)$/,
89 q/^(subcollection|format)$/,
90 q/^(acquire|plugin|classify)$/,
91 q/^(collectionmeta)$/);
92}
93sub read_collection_cfg_xml {
94 my ($filename) = @_;
95
96 return &cfgread4gs3::read_cfg_file ($filename);
97}
98sub write_collection_cfg_xml {
99
100}
101sub write_build_cfg_xml {
102 my ($buildoutfile, $buildcfg, $collectcfg) = @_;
103
104 return &cfgread4gs3::write_cfg_file ($buildoutfile, $buildcfg, $collectcfg);
105}
106
107sub write_collect_cfg {
108 my ($filename, $data) = @_;
109
110 &cfgread::write_cfg_file($filename, $data,
111 q/^(creator|public|defaultindex|importdir|/ .
112 q/archivedir|cachedir|builddir|removeold|/ .
113 q/textcompress|buildtype|no_text|keepold|gzip|/ .
114 q/verbosity|remove_empty_classifications|OIDtype|/.
115 q/groupsize|maxdocs|debug|mode|saveas|/ .
116 q/sortmeta|removesuffix|removeprefix|create_images|/ .
117 q/maxnumeric|separate_cjk|language_metadata/ .
118 q/no_strip_html|index|sections_index_document_metadata)$/,
119 q/^(maintainer|languages|indexsubcollections|/ .
120 q/indexes|indexoptions|dontbuild|dontgdbm|mirror|levels|/.
121 q/searchtype|searchtypes)$/,
122 q/^(subcollection|format)$/,
123 q/^(acquire|plugin|classify)$/,
124 q/^(collectionmeta)$/);
125}
126
127
128# the build configuration file data is stored in the form
129#
130# {'builddate'}->string
131# {'buildtype'}->string
132# {'metadata'}->array of strings
133# {'languages'}->array of strings
134# {'numdocs'}->string
135# {'numsections'}->string
136# {'numwords'}->string
137# {'numbytes'}->string
138# {'maxnumeric'}->string
139# {'indexfields'}->array of strings
140# {'indexfieldmap'}->array of strings in the form "field->FI"
141# {'indexmap'} -> array of strings
142# {'indexlevels'} -> array of strings
143# {'stemindexes'} -> string (int)
144# {'textlevel'}->string
145# {'levelmap'} -> array of strings in the form "level->shortname"
146sub read_build_cfg {
147 my ($filename) = @_;
148
149 return &cfgread::read_cfg_file ($filename,
150 q/^(builddate|buildtype|numdocs|numsections|numwords|numbytes|maxnumeric|textlevel|indexstem|stemindexes)$/,
151 q/^(indexmap|subcollectionmap|languagemap|notbuilt|indexfields|indexfieldmap|indexlevels|levelmap)$/);
152
153}
154
155sub write_build_cfg {
156 my ($filename, $data) = @_;
157
158 &cfgread::write_cfg_file($filename, $data,
159 q/^(builddate|buildtype|numdocs|numsections|numwords|numbytes|maxnumeric|textlevel|indexstem|stemindexes)$/,
160 q/^(indexmap|subcollectionmap|languagemap|notbuilt|indexfields|indexfieldmap|indexlevels|levelmap)$/);
161}
162
163sub get_collect_cfg_name {
164 my ($out) = @_;
165
166 # First check if there's a
167 # gsdl/collect/COLLECTION/custom/COLLECTION/etc/custom.cfg file. This
168 # customization was added for DLC by Stefan, 30/6/2007.
169 my $configfilename = &util::filename_cat ($ENV{'GSDLCOLLECTDIR'}, "custom", $ENV{'GSDLCOLLECTION'}, "etc", "custom.cfg");
170
171 if (-e $configfilename) {
172 return ($configfilename, "gs2");
173 }
174
175 # Now check if there is a collect.cfg file in the usual place, i.e. it is gs2.
176 $configfilename = &util::filename_cat ($ENV{'GSDLCOLLECTDIR'}, "etc", "collect.cfg");
177 if (-e $configfilename) {
178 return ($configfilename, "gs2");
179 }
180
181 # If we get to here we check if there is a collectionConfig.xml file,
182 # i.e. it is gs3.
183 $configfilename = &util::filename_cat ($ENV{'GSDLCOLLECTDIR'}, "etc", "collectionConfig.xml");
184 if (-e $configfilename) {
185 return ($configfilename, "gs3");
186 }
187
188 # Error. No collection configuration file.
189 (&gsprintf($out, "{common.cannot_find_cfg_file}\n", $configfilename) && die);
190}
191
1921;
193
Note: See TracBrowser for help on using the repository browser.