[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;
|
---|
[20097] | 31 | use collConfigxml;
|
---|
| 32 | use buildConfigxml;
|
---|
[14657] | 33 | use gsprintf 'gsprintf';
|
---|
| 34 | use strict;
|
---|
| 35 |
|
---|
| 36 | # the collection configuration file data is stored in the form
|
---|
| 37 | #
|
---|
[15724] | 38 | # {'infodbtype'}->string
|
---|
[14657] | 39 | # {'creator'}->string
|
---|
| 40 | # {'public'}->string
|
---|
| 41 | # {'defaultindex'}->string
|
---|
| 42 | # {'importdir'}->string
|
---|
| 43 | # {'archivedir'}->string
|
---|
| 44 | # {'cachedir'}->string
|
---|
| 45 | # {'builddir'}->string
|
---|
| 46 | # {'removeold'}->string
|
---|
| 47 | # {'textcompress'}->string
|
---|
| 48 | # {'buildtype'}->string
|
---|
| 49 | # {'maxnumeric'}->string
|
---|
| 50 | # {'separate_cjk'}->string
|
---|
| 51 | # {'sections_index_document_metadata'}->string (always, unless_section_metadata_exists)
|
---|
| 52 | # {'maintainer'}->array of strings
|
---|
| 53 | # {'languages'}->array of strings
|
---|
| 54 | # {'indexsubcollections'}->array of strings
|
---|
| 55 | # {'indexes'}->array of strings
|
---|
| 56 | # {'indexoptions'}->array of strings (stem, casefold, accentfold)
|
---|
| 57 | # {'dontbuild'}->array of strings
|
---|
| 58 | # {'dontgdbm'}->array of strings
|
---|
| 59 | # {'mirror'}->array of strings
|
---|
| 60 | # {'phind'}->array of strings
|
---|
| 61 | # {'plugout'}->array of strings
|
---|
| 62 | # {'levels'}->array of strings (for mgpp eg Section, Paragraph)
|
---|
| 63 | # {'searchtype'}->array of strings (for mgpp, form or plain)
|
---|
| 64 |
|
---|
| 65 | # {'subcollection'}->hash of key-value pairs
|
---|
| 66 |
|
---|
| 67 | # {'acquire'}->array of arrays of strings
|
---|
| 68 | # {'plugin'}->array of arrays of strings
|
---|
| 69 | # {'classify'}->array of arrays of strings
|
---|
| 70 |
|
---|
| 71 | # {'collectionmeta'}->hash of key->hash of param-value -used
|
---|
| 72 | # for language specification
|
---|
| 73 | # for example, collectionmeta->collectionname->default->demo
|
---|
| 74 | # ->mi->maori demo
|
---|
| 75 |
|
---|
| 76 | sub read_collect_cfg {
|
---|
| 77 | my ($filename) = @_;
|
---|
| 78 |
|
---|
| 79 | return &cfgread::read_cfg_file ($filename,
|
---|
[15724] | 80 | q/^(infodbtype|creator|public|defaultindex|importdir|/ .
|
---|
[14657] | 81 | q/archivedir|cachedir|builddir|removeold|/ .
|
---|
| 82 | q/textcompress|buildtype|no_text|keepold|gzip|/ .
|
---|
[18528] | 83 | q/verbosity|remove_empty_classifications|OIDtype|OIDmetadata|/ .
|
---|
[14657] | 84 | q/groupsize|maxdocs|debug|mode|saveas|/ .
|
---|
| 85 | q/sortmeta|removesuffix|removeprefix|create_images|/ .
|
---|
[17109] | 86 | q/maxnumeric|languagemetadata|/ .
|
---|
[16222] | 87 | q/no_strip_html|index|sections_index_document_metadata|/ .
|
---|
| 88 | q/store_metadata_coverage)$/,
|
---|
[14657] | 89 | q/(maintainer|languages|indexsubcollections|/ .
|
---|
| 90 | q/indexes|indexoptions|dontbuild|dontgdbm|mirror|levels|plugout|/ .
|
---|
| 91 | q/searchtype|searchtypes)$/,
|
---|
| 92 | q/^(subcollection|format)$/,
|
---|
| 93 | q/^(acquire|plugin|classify)$/,
|
---|
| 94 | q/^(collectionmeta)$/);
|
---|
| 95 | }
|
---|
[19751] | 96 |
|
---|
[14657] | 97 | sub read_collection_cfg_xml {
|
---|
| 98 | my ($filename) = @_;
|
---|
| 99 |
|
---|
[20097] | 100 | return &collConfigxml::read_cfg_file ($filename);
|
---|
[14657] | 101 | }
|
---|
[19751] | 102 |
|
---|
| 103 | sub read_collection_cfg {
|
---|
| 104 | my ($filename,$gs_mode) = @_;
|
---|
| 105 |
|
---|
| 106 | my $collectcfg = undef;
|
---|
| 107 |
|
---|
| 108 | if ($gs_mode eq "gs2") {
|
---|
| 109 | $collectcfg = &colcfg::read_collect_cfg ($filename);
|
---|
| 110 | } elsif ($gs_mode eq "gs3") {
|
---|
| 111 | $collectcfg = &colcfg::read_collection_cfg_xml ($filename);
|
---|
| 112 | }
|
---|
| 113 | else {
|
---|
| 114 | print STDERR "Failed to read collection configuration file\n";
|
---|
| 115 | print STDERR " Unrecognized mode: $gs_mode\n";
|
---|
| 116 | }
|
---|
| 117 |
|
---|
| 118 | return $collectcfg;
|
---|
| 119 | }
|
---|
| 120 |
|
---|
| 121 |
|
---|
| 122 |
|
---|
[14657] | 123 | sub write_collection_cfg_xml {
|
---|
| 124 |
|
---|
| 125 | }
|
---|
[19751] | 126 |
|
---|
[14657] | 127 | sub write_build_cfg_xml {
|
---|
| 128 | my ($buildoutfile, $buildcfg, $collectcfg, $disable_OAI) = @_;
|
---|
| 129 |
|
---|
[20097] | 130 | return &buildConfigxml::write_build_cfg_file ($buildoutfile, $buildcfg, $collectcfg, $disable_OAI);
|
---|
[14657] | 131 | }
|
---|
| 132 |
|
---|
| 133 | sub write_collect_cfg {
|
---|
| 134 | my ($filename, $data) = @_;
|
---|
| 135 |
|
---|
| 136 | &cfgread::write_cfg_file($filename, $data,
|
---|
[15724] | 137 | q/^(infodbtype|creator|public|defaultindex|importdir|/ .
|
---|
[14657] | 138 | q/archivedir|cachedir|builddir|removeold|/ .
|
---|
| 139 | q/textcompress|buildtype|no_text|keepold|gzip|/ .
|
---|
[18528] | 140 | q/verbosity|remove_empty_classifications|OIDtype|OIDmetadata|/.
|
---|
[14657] | 141 | q/groupsize|maxdocs|debug|mode|saveas|/ .
|
---|
| 142 | q/sortmeta|removesuffix|removeprefix|create_images|/ .
|
---|
[17109] | 143 | q/maxnumeric|language_metadata/ .
|
---|
[14657] | 144 | q/no_strip_html|index|sections_index_document_metadata)$/,
|
---|
| 145 | q/^(maintainer|languages|indexsubcollections|/ .
|
---|
| 146 | q/indexes|indexoptions|dontbuild|dontgdbm|mirror|levels|/.
|
---|
| 147 | q/searchtype|searchtypes)$/,
|
---|
| 148 | q/^(subcollection|format)$/,
|
---|
| 149 | q/^(acquire|plugin|classify)$/,
|
---|
| 150 | q/^(collectionmeta)$/);
|
---|
| 151 | }
|
---|
| 152 |
|
---|
| 153 |
|
---|
| 154 | # the build configuration file data is stored in the form
|
---|
| 155 | #
|
---|
[15728] | 156 | # {'infodbtype'}->string
|
---|
[14657] | 157 | # {'builddate'}->string
|
---|
| 158 | # {'buildtype'}->string
|
---|
| 159 | # {'metadata'}->array of strings
|
---|
| 160 | # {'languages'}->array of strings
|
---|
| 161 | # {'numdocs'}->string
|
---|
| 162 | # {'numsections'}->string
|
---|
| 163 | # {'numwords'}->string
|
---|
| 164 | # {'numbytes'}->string
|
---|
| 165 | # {'maxnumeric'}->string
|
---|
| 166 | # {'indexfields'}->array of strings
|
---|
| 167 | # {'indexfieldmap'}->array of strings in the form "field->FI"
|
---|
| 168 | # {'indexmap'} -> array of strings
|
---|
| 169 | # {'indexlevels'} -> array of strings
|
---|
| 170 | # {'stemindexes'} -> string (int)
|
---|
| 171 | # {'textlevel'}->string
|
---|
| 172 | # {'levelmap'} -> array of strings in the form "level->shortname"
|
---|
| 173 | sub read_build_cfg {
|
---|
| 174 | my ($filename) = @_;
|
---|
| 175 |
|
---|
| 176 | return &cfgread::read_cfg_file ($filename,
|
---|
[17109] | 177 | q/^(infodbtype|builddate|buildtype|numdocs|numsections|numwords|numbytes|maxnumeric|textlevel|indexstem|stemindexes|separate_cjk)$/,
|
---|
[14657] | 178 | q/^(indexmap|subcollectionmap|languagemap|notbuilt|indexfields|indexfieldmap|indexlevels|levelmap)$/);
|
---|
| 179 |
|
---|
| 180 | }
|
---|
| 181 |
|
---|
| 182 | sub write_build_cfg {
|
---|
| 183 | my ($filename, $data) = @_;
|
---|
| 184 |
|
---|
| 185 | &cfgread::write_cfg_file($filename, $data,
|
---|
[17109] | 186 | q/^(infodbtype|builddate|buildtype|numdocs|numsections|numwords|numbytes|maxnumeric|textlevel|indexstem|stemindexes|separate_cjk)$/,
|
---|
[14657] | 187 | q/^(indexmap|subcollectionmap|languagemap|notbuilt|indexfields|indexfieldmap|indexlevels|levelmap)$/);
|
---|
| 188 | }
|
---|
| 189 |
|
---|
| 190 | sub get_collect_cfg_name {
|
---|
| 191 | my ($out) = @_;
|
---|
| 192 |
|
---|
| 193 | # First check if there's a
|
---|
| 194 | # gsdl/collect/COLLECTION/custom/COLLECTION/etc/custom.cfg file. This
|
---|
| 195 | # customization was added for DLC by Stefan, 30/6/2007.
|
---|
| 196 | my $configfilename = &util::filename_cat ($ENV{'GSDLCOLLECTDIR'}, "custom", $ENV{'GSDLCOLLECTION'}, "etc", "custom.cfg");
|
---|
| 197 |
|
---|
| 198 | if (-e $configfilename) {
|
---|
| 199 | return ($configfilename, "gs2");
|
---|
| 200 | }
|
---|
| 201 |
|
---|
| 202 | # Now check if there is a collect.cfg file in the usual place, i.e. it is gs2.
|
---|
| 203 | $configfilename = &util::filename_cat ($ENV{'GSDLCOLLECTDIR'}, "etc", "collect.cfg");
|
---|
| 204 | if (-e $configfilename) {
|
---|
| 205 | return ($configfilename, "gs2");
|
---|
| 206 | }
|
---|
| 207 |
|
---|
| 208 | # If we get to here we check if there is a collectionConfig.xml file,
|
---|
| 209 | # i.e. it is gs3.
|
---|
| 210 | $configfilename = &util::filename_cat ($ENV{'GSDLCOLLECTDIR'}, "etc", "collectionConfig.xml");
|
---|
| 211 | if (-e $configfilename) {
|
---|
| 212 | return ($configfilename, "gs3");
|
---|
| 213 | }
|
---|
| 214 |
|
---|
| 215 | # Error. No collection configuration file.
|
---|
| 216 | (&gsprintf($out, "{common.cannot_find_cfg_file}\n", $configfilename) && die);
|
---|
| 217 | }
|
---|
| 218 |
|
---|
[14926] | 219 |
|
---|
| 220 | sub use_collection {
|
---|
| 221 | my ($site, $collection, $collectdir) = @_;
|
---|
| 222 |
|
---|
| 223 | if ((defined $site) && ($site ne ""))
|
---|
| 224 | {
|
---|
| 225 | return &util::use_site_collection($site, $collection, $collectdir);
|
---|
| 226 | }
|
---|
| 227 | else
|
---|
| 228 | {
|
---|
| 229 | return &util::use_collection($collection, $collectdir);
|
---|
| 230 | }
|
---|
| 231 | }
|
---|
| 232 |
|
---|
| 233 |
|
---|
[14657] | 234 | 1;
|
---|
| 235 |
|
---|
[14926] | 236 |
|
---|