[14657] | 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 |
|
---|
| 28 | package colcfg;
|
---|
| 29 |
|
---|
| 30 | use cfgread;
|
---|
| 31 | use cfgread4gs3;
|
---|
| 32 | use gsprintf 'gsprintf';
|
---|
| 33 | use strict;
|
---|
| 34 |
|
---|
| 35 | # the collection configuration file data is stored in the form
|
---|
| 36 | #
|
---|
[15723] | 37 | # {'dbtype'}->string
|
---|
[14657] | 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 |
|
---|
| 75 | sub read_collect_cfg {
|
---|
| 76 | my ($filename) = @_;
|
---|
| 77 |
|
---|
| 78 | return &cfgread::read_cfg_file ($filename,
|
---|
[15723] | 79 | q/^(dbtype|creator|public|defaultindex|importdir|/ .
|
---|
[14657] | 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 | }
|
---|
| 94 | sub read_collection_cfg_xml {
|
---|
| 95 | my ($filename) = @_;
|
---|
| 96 |
|
---|
| 97 | return &cfgread4gs3::read_cfg_file ($filename);
|
---|
| 98 | }
|
---|
| 99 | sub write_collection_cfg_xml {
|
---|
| 100 |
|
---|
| 101 | }
|
---|
| 102 | sub 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 |
|
---|
| 108 | sub write_collect_cfg {
|
---|
| 109 | my ($filename, $data) = @_;
|
---|
| 110 |
|
---|
| 111 | &cfgread::write_cfg_file($filename, $data,
|
---|
[15723] | 112 | q/^(dbtype|creator|public|defaultindex|importdir|/ .
|
---|
[14657] | 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 | # {'builddate'}->string
|
---|
| 132 | # {'buildtype'}->string
|
---|
| 133 | # {'metadata'}->array of strings
|
---|
| 134 | # {'languages'}->array of strings
|
---|
| 135 | # {'numdocs'}->string
|
---|
| 136 | # {'numsections'}->string
|
---|
| 137 | # {'numwords'}->string
|
---|
| 138 | # {'numbytes'}->string
|
---|
| 139 | # {'maxnumeric'}->string
|
---|
| 140 | # {'indexfields'}->array of strings
|
---|
| 141 | # {'indexfieldmap'}->array of strings in the form "field->FI"
|
---|
| 142 | # {'indexmap'} -> array of strings
|
---|
| 143 | # {'indexlevels'} -> array of strings
|
---|
| 144 | # {'stemindexes'} -> string (int)
|
---|
| 145 | # {'textlevel'}->string
|
---|
| 146 | # {'levelmap'} -> array of strings in the form "level->shortname"
|
---|
| 147 | sub read_build_cfg {
|
---|
| 148 | my ($filename) = @_;
|
---|
| 149 |
|
---|
| 150 | return &cfgread::read_cfg_file ($filename,
|
---|
| 151 | q/^(builddate|buildtype|numdocs|numsections|numwords|numbytes|maxnumeric|textlevel|indexstem|stemindexes)$/,
|
---|
| 152 | q/^(indexmap|subcollectionmap|languagemap|notbuilt|indexfields|indexfieldmap|indexlevels|levelmap)$/);
|
---|
| 153 |
|
---|
| 154 | }
|
---|
| 155 |
|
---|
| 156 | sub write_build_cfg {
|
---|
| 157 | my ($filename, $data) = @_;
|
---|
| 158 |
|
---|
| 159 | &cfgread::write_cfg_file($filename, $data,
|
---|
| 160 | q/^(builddate|buildtype|numdocs|numsections|numwords|numbytes|maxnumeric|textlevel|indexstem|stemindexes)$/,
|
---|
| 161 | q/^(indexmap|subcollectionmap|languagemap|notbuilt|indexfields|indexfieldmap|indexlevels|levelmap)$/);
|
---|
| 162 | }
|
---|
| 163 |
|
---|
| 164 | sub get_collect_cfg_name {
|
---|
| 165 | my ($out) = @_;
|
---|
| 166 |
|
---|
| 167 | # First check if there's a
|
---|
| 168 | # gsdl/collect/COLLECTION/custom/COLLECTION/etc/custom.cfg file. This
|
---|
| 169 | # customization was added for DLC by Stefan, 30/6/2007.
|
---|
| 170 | my $configfilename = &util::filename_cat ($ENV{'GSDLCOLLECTDIR'}, "custom", $ENV{'GSDLCOLLECTION'}, "etc", "custom.cfg");
|
---|
| 171 |
|
---|
| 172 | if (-e $configfilename) {
|
---|
| 173 | return ($configfilename, "gs2");
|
---|
| 174 | }
|
---|
| 175 |
|
---|
| 176 | # Now check if there is a collect.cfg file in the usual place, i.e. it is gs2.
|
---|
| 177 | $configfilename = &util::filename_cat ($ENV{'GSDLCOLLECTDIR'}, "etc", "collect.cfg");
|
---|
| 178 | if (-e $configfilename) {
|
---|
| 179 | return ($configfilename, "gs2");
|
---|
| 180 | }
|
---|
| 181 |
|
---|
| 182 | # If we get to here we check if there is a collectionConfig.xml file,
|
---|
| 183 | # i.e. it is gs3.
|
---|
| 184 | $configfilename = &util::filename_cat ($ENV{'GSDLCOLLECTDIR'}, "etc", "collectionConfig.xml");
|
---|
| 185 | if (-e $configfilename) {
|
---|
| 186 | return ($configfilename, "gs3");
|
---|
| 187 | }
|
---|
| 188 |
|
---|
| 189 | # Error. No collection configuration file.
|
---|
| 190 | (&gsprintf($out, "{common.cannot_find_cfg_file}\n", $configfilename) && die);
|
---|
| 191 | }
|
---|
| 192 |
|
---|
[14926] | 193 |
|
---|
| 194 | sub use_collection {
|
---|
| 195 | my ($site, $collection, $collectdir) = @_;
|
---|
| 196 |
|
---|
| 197 | if ((defined $site) && ($site ne ""))
|
---|
| 198 | {
|
---|
| 199 | return &util::use_site_collection($site, $collection, $collectdir);
|
---|
| 200 | }
|
---|
| 201 | else
|
---|
| 202 | {
|
---|
| 203 | return &util::use_collection($collection, $collectdir);
|
---|
| 204 | }
|
---|
| 205 | }
|
---|
| 206 |
|
---|
| 207 |
|
---|
[14657] | 208 | 1;
|
---|
| 209 |
|
---|
[14926] | 210 |
|
---|