source: gsdl/trunk/perllib/cfgread4gs3.pm@ 14244

Last change on this file since 14244 was 14244, checked in by xiao, 14 years ago

modification to receive the disable_OAI flag directly instead of using the build_cfg structure which might cause perl regular expression compilation warnings.

  • Property svn:keywords set to Author Date Id Revision
File size: 23.1 KB
Line 
1###########################################################################
2#
3# cfgread4gs3.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 configuration files of xml form
27
28package cfgread4gs3;
29use strict;
30no strict 'refs';
31no strict 'subs';
32
33# Wrapper that ensures the right version of XML::Parser is loaded given
34# the version of Perl being used. Need to distinguish between Perl 5.6 and
35# Perl 5.8
36sub BEGIN {
37 my $perl_dir;
38
39 # Note: $] encodes the version number of perl
40 if ($]>5.008) {
41 # perl 5.8.1 or above
42 $perl_dir = "perl-5.8";
43 }
44 elsif ($]<5.008) {
45 # assume perl 5.6
46 $perl_dir = "perl-5.6";
47 }
48 else {
49 print STDERR "Warning: Perl 5.8.0 is not a maintained release.\n";
50 print STDERR " Please upgrade to a newer version of Perl.\n";
51 $perl_dir = "perl-5.8";
52 }
53
54 if ($ENV{'GSDLOS'} !~ /^windows$/i) {
55 # Use push to put this on the end, so an existing XML::Parser will be used by default
56 push (@INC, "$ENV{'GSDLHOME'}/perllib/cpan/$perl_dir");
57 }
58}
59
60use XML::Parser;
61
62# A mapping hash to resolve name descrepency between gs2 and gs3.
63my $nameMap = {"key" => "value",
64 "creator" => "creator",
65 "maintainer" => "maintainer",
66 "public" => "public",
67 "defaultIndex" => "defaultindex",
68 "defaultLevel" => "defaultlevel",
69 "name" => "collectionname",
70 "description" => "collectionextra",
71 "smallicon" => "iconcollectionsmall",
72 "icon" => "iconcollection",
73 "level" => "levels",
74 "classifier" => "classify",
75 "indexSubcollection" => "indexsubcollections",
76 "indexLanguage" => "languages",
77 "defaultIndexLanguage" => "defaultlanguage",
78 "index" => "indexes",
79 "plugin" => "plugin",
80 "indexOption" => "indexoptions",
81 "searchType" => "searchtype",
82 "languageMetadata" => "languagemetadata",
83 };
84# A hash structure which is returned by sub read_cfg_file.
85my $data = {};
86
87my $repeatedBlock = q/^(browse|pluginList)$/;
88
89# use those unique attribute values to locate the text within the elements
90# creator, public, maintainer.
91my $currentLocation = "";
92my $stringexp = q/^(creator|maintainer|public)$/;
93
94my $currentLevel = "";
95
96# Count the elements with same name within the same block
97# ("plugin", "option")
98my $currentIndex = 0;
99my $arrayexp = q/^(index|level|indexSubcollection|indexLanguage)$/;
100my $arrayarrayexp= q/^(plugin|classifier)$/;
101
102my $defaults = q/^(defaultIndex|defaultLevel|defaultIndexLanguage|languageMetadata)$/;
103
104sub StartTag {
105# Those marked with #@ will not be executed at the same time when this sub is being called
106# so that if/elsif is used to avoid unnecessary tests
107 my ($expat, $element) = @_;
108
109 my $name = $_{'name'};
110 my $value = $_{'value'};
111 my $type = $_{'type'};
112
113 # for subcollections
114 my $filter = $_{'filter'};
115
116 #@ Marking repeated block
117 if ($element =~ /$repeatedBlock/) {
118 $currentIndex = 0;
119 }
120
121 #@ handling block metadataList
122 elsif (defined $name and $name =~ /$stringexp/){
123 $currentLocation = $name;
124 }
125 #@ handling default search index/level/indexLanguage and languageMetadata
126 elsif ($element =~ /$defaults/) {
127 if (defined $name and $name =~ /\w/) {
128 $data->{$nameMap->{$element}} = $name;
129 }
130 }
131
132 #@ Handling indexer: mgpp/mg/lucene; stringexp
133 elsif ($element eq "search") {
134 $data->{'buildtype'} = $type;
135 }
136
137 #@ Handling searchtype: plain,form; arrayexp
138 #elsif ($element eq "format" and defined $name and $name =~ /searchType/) {
139 #@ Handling searchtype: plain, form
140 #$currentLocation = $name;
141 #}
142
143 #@ Handle index|level|indexSubcollection|indexLanguage
144 elsif ($element =~ /$arrayexp/) {
145 my $key = $nameMap->{$element};
146 if (!defined $data->{$key}) {
147 $data->{$key} = [];
148 }
149
150 push (@{$data->{$key}},$name);
151 }
152
153 #@ indexoptions: accentfold/casefold/stem; arrayexp
154 elsif ($element eq "indexOption") {
155 $currentLevel = "indexOption";
156 }
157 if ($currentLevel eq "indexOption" and $element eq "option") {
158 my $key = $nameMap->{$currentLevel};
159 if (!defined $data->{$key}) {
160 $data->{$key} = [];
161 }
162 push (@{$data->{$key}},$name);
163 }
164
165 #@ use hash of hash of strings: hashexp
166 elsif ($element eq "subcollection") {
167 if (!defined $data->{'subcollection'}) {
168 $data->{'subcollection'} = {};
169 }
170 if (defined $name and $name =~ /\w/) {
171 if (defined $filter and $filter =~ /\w/) {
172 $data->{'subcollection'}->{$name} = $filter;
173
174 }
175 }
176 }
177
178 #@ Handling each classifier/plugin element
179 elsif ($element =~ /$arrayarrayexp/) {
180 # find the gs2 mapping name
181 $currentLevel = $element;
182 my $key = $nameMap->{$element};
183
184 # define an array of array of strings foreach $k (@{$data->{$key}}) {
185 if (!defined $data->{$key}) {
186 $data->{$key} = [];
187 }
188 # Push classifier/plugin name (e.g. AZList) into $data as the first string
189 push (@{$data->{$key}->[$currentIndex]},$name);
190 #print $currentIndex."indexup\n";
191 }
192
193 #@ Handling the option elements in each classifier/plugin element (as the following strings)
194 elsif ($currentLevel =~ /$arrayarrayexp/ and $element eq "option") {
195 # find the gs2 mapping name for classifier and plugin
196 my $key = $nameMap->{$currentLevel};
197
198 if (defined $name and $name =~ /\w/) {
199 push (@{$data->{$key}->[$currentIndex]}, $name);
200 }
201 if (defined $value and $value =~ /\w/) {
202 push (@{$data->{$key}->[$currentIndex]}, $value);
203 }
204
205 }
206
207}
208
209sub EndTag {
210 my ($expat, $element) = @_;
211 my $endTags = q/^(browse|pluginList)$/;
212 if ($element =~ /$endTags/) {
213 $currentIndex = 0;
214 $currentLevel = "";
215 }
216 # $arrayarrayexp contains classifier|plugin
217 elsif($element =~ /$arrayarrayexp/){
218 $currentIndex = $currentIndex + 1;
219 }
220
221}
222
223sub Text {
224 #@ Handling block metadataList(creator, maintainer, public)
225 if (defined $currentLocation and $currentLocation =~ /$stringexp/){
226 #print $currentLocation;
227 my $key = $nameMap->{$currentLocation};
228 $data->{$key} = $_;
229 undef $currentLocation;
230 }
231 #@ Handling searchtype: plain,form; arrayexp
232 if (defined $currentLocation and $currentLocation =~ /searchType/) {
233 # map 'searchType' into 'searchtype'
234 my $key = $nameMap->{$currentLocation};
235 # split it by ','
236 my ($plain, $form) = split (",", $_);
237
238 if (!defined $data->{$key}) {
239 $data->{$key} = [];
240 }
241 if (defined $plain and $plain =~ /\w/) {
242 push @{ $data->{$key} }, $plain;
243 }
244 if (defined $form and $form =~ /\w/) {
245 push @{ $data->{$key} }, $form;
246 }
247 }
248}
249# This sub is for debugging purposes
250sub Display {
251 # metadataList
252
253 print $data->{'creator'}."\n" if (defined $data->{'creator'});
254 print $data->{"maintainer"}."\n" if (defined $data->{"maintainer"});
255 print $data->{"public"}."\n" if (defined $data->{"public"});
256 print $data->{"defaultindex"}."\n" if (defined $data->{"defaultindex"});
257 print $data->{"defaultlevel"}."\n" if (defined $data->{"defaultlevel"});
258 print $data->{"buildtype"}."\n" if (defined $data->{"buildtype"});
259 print join(",",@{$data->{"searchtype"}})."\n" if (defined $data->{"searchtype"});
260 print join(",",@{$data->{'levels'}})."\n" if (defined $data->{'levels'});
261 print join(",",@{$data->{'indexsubcollections'}})."\n" if (defined $data->{'indexsubcollections'});
262 print join(",",@{$data->{'indexes'}})."\n" if (defined $data->{'indexes'});
263 print join(",",@{$data->{'indexoptions'}})."\n" if (defined $data->{'indexoptions'});
264 print join(",",@{$data->{'languages'}})."\n" if (defined $data->{'languages'});
265 print join(",",@{$data->{'languagemetadata'}})."\n" if (defined $data->{'languagemetadata'});
266
267 if (defined $data->{'plugin'}) {
268 foreach $a (@{$data->{'plugin'}}) {
269 print join(",",@$a);
270 print "\n";
271 }
272 }
273 if (defined $data->{'classify'}) {
274 print "Classifiers: \n";
275 map { print join(",",@$_)."\n"; } @{$data->{'classify'}};
276 }
277
278 if (defined $data->{'subcollection'}) {
279 foreach my $key (keys %{$data->{'subcollection'}}) {
280 print "subcollection ".$key." ".$data->{'subcollection'}->{$key}."\n";
281 }
282 }
283}
284sub Doctype {
285 my ($expat, $name, $sysid, $pubid, $internal) = @_;
286
287 # allow the short-lived and badly named "GreenstoneDirectoryMetadata" files
288 # to be processed as well as the "DirectoryMetadata" files which should now
289 # be created by import.pl
290 die if ($name !~ /^(Greenstone)?DirectoryMetadata$/);
291}
292
293# This Char function overrides the one in XML::Parser::Stream to overcome a
294# problem where $expat->{Text} is treated as the return value, slowing
295# things down significantly in some cases.
296sub Char {
297 if ($]<5.008) {
298 use bytes; # Necessary to prevent encoding issues with XML::Parser 2.31+ and Perl 5.6
299 }
300 $_[0]->{'Text'} .= $_[1];
301 return undef;
302}
303# Reads in the model collection configuration file, collectionConfig.xml,
304# into a structure which complies with the one used by gs2 (i.e. one read
305# in by &cfgread::read_cfg_file).
306sub read_cfg_file {
307 my ($filename) = @_;
308 $data = {};
309 if ($filename !~ /collectionConfig\.xml$/ || !-f $filename) {
310 return undef;
311 }
312
313 # create XML::Parser object for parsing metadata.xml files
314 my $parser;
315 if ($]<5.008) {
316 # Perl 5.6
317 $parser = new XML::Parser('Style' => 'Stream',
318 'Handlers' => {'Char' => \&Char,
319 'Doctype' => \&Doctype
320 });
321 }
322 else {
323 # Perl 5.8
324 $parser = new XML::Parser('Style' => 'Stream',
325 'ProtocolEncoding' => 'ISO-8859-1',
326 'Handlers' => {'Char' => \&Char,
327 'Doctype' => \&Doctype
328 });
329 }
330
331 if (!open (COLCFG, $filename)) {
332 print STDERR "cfgread::read_cfg_file couldn't read the cfg file $filename\n";
333 } else {
334
335 $parser->parsefile ($filename);# (COLCFG);
336 close (COLCFG);
337 }
338
339 #print "*** collectionConfig.xml internal ***\n";
340 #&Display;
341 return $data;
342}
343
344
345sub write_line {
346 my ($filehandle, $line) = @_;
347 print $filehandle join ("", @$line), "\n";
348}
349
350# Create the buildConfig.xml file for a specific collection
351sub write_cfg_file {
352 # this sub is called in make_auxiliary_files() in basebuilder.pm
353 # the received args: $buildoutfile - destination file: buildConfig.xml
354 # $buildcfg - all build options, eg, disable_OAI
355 # $collectcfg - contents of collectionConfig.xml read in by read_cfg_file sub in cfgread4gs3.pm.
356 my ($buildoutfile, $buildcfg, $collectcfg, $disable_OAI) = @_;
357 my $line = [];
358
359 if (!open (COLCFG, ">$buildoutfile")) {
360 print STDERR "cfgread4gs3::write_cfg_file couldn't write the build config file $buildoutfile\n";
361 die;
362 }
363
364 &write_line('COLCFG', ["<buildConfig xmlns:gsf=\"http://www.greenstone.org/greenstone3/schema/ConfigFormat\">"]);
365
366 # output building metadata to build config file
367 my $buildtype;
368 if (defined $buildcfg->{"buildtype"}) {
369 $buildtype = $buildcfg->{"buildtype"};
370 } else {
371 $buildtype = "mgpp";
372 }
373 my $numdocs;
374 if (defined $buildcfg->{"numdocs"}) {
375 $numdocs = $buildcfg->{"numdocs"};
376 }
377 &write_line('COLCFG', ["<metadataList>"]);
378 &write_line('COLCFG', ["<metadata name=\"numDocs\">", $numdocs, "</metadata>"]);
379 &write_line('COLCFG', ["<metadata name=\"buildType\">", $buildtype, "</metadata>"]);
380 &write_line('COLCFG', ["</metadataList>"]);
381
382 my $service_type = "MGPP";
383 if ($buildtype eq "mg") {
384 $service_type = "MG";
385 } elsif ($buildtype eq "lucene") {
386 $service_type = "Lucene";
387 }
388
389 # output serviceRackList
390 &write_line('COLCFG', ["<serviceRackList>"]);
391
392 # This serviceRack enables the collection to provide the oai metadata retrieve service, which is served by the OAIPMH.java class
393 # For each collection, we write the following serviceRack in the collection's buildConfig.xml file if the 'disable_OAI' argument is not checked in the GLI (or equivalently, a 'disable_OAI' flag is not specified on the command line). There are also other configurations in the OAIConfig.xml.
394 if ($disable_OAI == 0) {
395 &write_line('COLCFG', ["<serviceRack name=\"OAIPMH\">"]);
396 if (defined $buildcfg->{'indexstem'}) {
397 my $indexstem = $buildcfg->{'indexstem'};
398 &write_line('COLCFG', ["<indexStem name=\"", $indexstem, "\" />"]);
399 }
400 &write_line('COLCFG', ["</serviceRack>"]);
401 }
402 # do the search service
403 &write_line('COLCFG', ["<serviceRack name=\"GS2", $service_type, "Search\">"]);
404 if (defined $buildcfg->{'indexstem'}) {
405 my $indexstem = $buildcfg->{'indexstem'};
406 &write_line('COLCFG', ["<indexStem name=\"", $indexstem, "\" />"]);
407 }
408
409 #indexes
410 # maps index name to shortname
411 my $indexmap = {};
412 # keeps the order for indexes
413 my @indexlist = ();
414
415 my $defaultindex = "";
416 my $first = 1;
417 my $maptype = "indexfieldmap";
418 if ($buildtype eq "mg") {
419 $maptype = "indexmap";
420 }
421
422 #map {print $_."\n"} keys %$buildcfg;
423
424 if (defined $buildcfg->{$maptype}) {
425 my $indexmap_t = $buildcfg->{$maptype};
426 foreach my $i (@$indexmap_t) {
427 my ($k, $v) = $i =~ /^(.*)\-\>(.*)$/;
428 $indexmap->{$k} = $v;
429 push @indexlist, $k;
430 if ($first) {
431 $defaultindex = $v;
432 $first = 0;
433 }
434 }
435 # now if the user has assigned a default index, we use it
436 if (defined $collectcfg->{"defaultindex"}) {
437 $defaultindex = $indexmap->{$collectcfg->{"defaultindex"}};
438 }
439
440 } else {
441 print STDERR "$maptype not defined";
442 }
443 #for each index in indexList, write them out
444 &write_line('COLCFG', ["<indexList>"]);
445 foreach my $i (@indexlist) {
446 my $index = $indexmap->{$i};
447 &write_line('COLCFG', ["<index name=\"", $i, "\" ", "shortname=\"", $index, "\" />"]);
448 }
449 &write_line('COLCFG', ["</indexList>"]);
450
451 # do default index only for mg
452 if ($buildtype eq "mg") {
453 &write_line('COLCFG', ["<defaultIndex shortname=\"", $defaultindex, "\" />"]);
454 }
455
456 # do indexOptionList
457 if ($buildtype eq "mg" || $buildtype eq "mgpp") {
458 &write_line('COLCFG', ["<indexOptionList>"]);
459 my $stemindexes = 3; # default is stem and casefold
460 if (defined $buildcfg->{'stemindexes'} && $buildcfg->{'stemindexes'} =~ /^\d+$/ ) {
461 $stemindexes = $buildcfg->{'stemindexes'};
462 }
463 &write_line('COLCFG', ["<indexOption name=\"stemIndexes\" value=\"", $stemindexes, "\" />"]);
464
465 my $maxnumeric = 4; # default
466 if (defined $buildcfg->{'maxnumeric'} && $buildcfg->{'maxnumeric'} =~ /^\d+$/) {
467 $maxnumeric = $buildcfg->{'maxnumeric'};
468 }
469 &write_line('COLCFG', ["<indexOption name=\"maxnumeric\" value=\"", $maxnumeric, "\" />"]);
470 &write_line('COLCFG', ["</indexOptionList>"]);
471 }
472
473 # levelList
474 my $levelmap = {};
475 my @levellist = ();
476 my $default_search_level = "Doc";
477 my $default_retrieve_level = "Doc";
478 my $default_gdbm_level = "Doc";
479 $first = 1;
480 if ($buildtype eq "mgpp" || $buildtype eq "lucene") {
481 if (defined $buildcfg->{'levelmap'}) {
482 my $levelmap_t = $buildcfg->{'levelmap'};
483 foreach my $l (@$levelmap_t) {
484 my ($key, $val) = $l =~ /^(.*)\-\>(.*)$/;
485 $levelmap->{$key} = $val;
486 push @levellist, $key;
487 if ($first) {
488 # let default search level follow the first level in the level list
489 $default_search_level = $val;
490 # retrieve/GDBM levels may get modified later if text level is defined
491 $default_retrieve_level = $val;
492 $default_gdbm_level = $val;
493 $first = 0;
494 }
495 }
496 }
497 # even if the user has assigned a default level, we ignore it. Why?
498 # I don't know, but it seems it's the way how the serving works
499 #if (defined $collectcfg->{"defaultlevel"}) {
500 # $default_search_level = $levelmap->{$collectcfg->{"defaultlevel"}};
501 # $default_retrieve_level = $default_search_level;
502 #}
503
504 if (defined $buildcfg->{'textlevel'}) {
505 # let the retrieve/gdbm levels always follow the textlevel
506 $default_retrieve_level = $buildcfg->{'textlevel'};
507 $default_gdbm_level = $buildcfg->{'textlevel'};
508
509 }
510 }
511 #for each level in levelList, write them out
512 if ($buildtype ne "mg") {
513 &write_line('COLCFG', ["<levelList>"]);
514 foreach my $lv (@levellist) {
515 my $level = $levelmap->{$lv};
516 &write_line('COLCFG', ["<level name=\"", $lv, "\" shortname=\"", $level, "\" />"]);
517 }
518 &write_line('COLCFG', ["</levelList>"]);
519 }
520 # add in defaultLevel as the same level as indexLevelList, making the reading job easier
521 if ($buildtype eq "lucene" || $buildtype eq "mgpp") {
522 &write_line('COLCFG', ["<defaultLevel shortname=\"", $default_search_level, "\" />"]);
523 }
524 if ($buildtype eq "lucene" || $buildtype eq "mgpp") {
525 # make the GDBM level
526 &write_line('COLCFG', ["<defaultGDBMLevel shortname=\"", $default_gdbm_level, "\" />"]);
527 }
528 # do searchTypeList
529 if ($buildtype eq "mgpp" || $buildtype eq "lucene") {
530 &write_line('COLCFG', ["<searchTypeList>"]);
531
532 if (defined $buildcfg->{"searchtype"}) {
533 my $searchtype_t = $buildcfg->{"searchtype"};
534 foreach my $s (@$searchtype_t) {
535 &write_line('COLCFG', ["<searchType name=\"", $s, "\" />"]);
536 }
537 } else {
538 &write_line('COLCFG', ["<searchType name=\"plain\" />"]);
539 &write_line('COLCFG', ["<searchType name=\"form\" />"]);
540 }
541 &write_line('COLCFG', ["</searchTypeList>"]);
542 }
543
544 # do indexLanguageList [in collect.cfg: languages; in build.cfg: languagemap]
545 $first = 1;
546 my $default_lang = "";
547 my $default_lang_short = "";
548 if (defined $buildcfg->{"languagemap"}) {
549 &write_line('COLCFG', ["<indexLanguageList>"]);
550
551 my $langmap_t = $buildcfg->{"languagemap"};
552 foreach my $l (@$langmap_t) {
553 my ($k, $v) = $l =~ /^(.*)\-\>(.*)$/;
554
555 &write_line('COLCFG', ["<indexLanguage name=\"", $k, "\" shortname=\"", $v, "\" />"]);
556 if ($first) {
557 $default_lang = $k; #name
558 $default_lang_short = $v; #shortname
559 $first = 0;
560 }
561 }
562
563 &write_line('COLCFG', ["</indexLanguageList>"]);
564 # now if the user has assigned a default language (as "en", "ru" etc.)
565 if (defined $collectcfg->{"defaultlanguage"}) {
566 $default_lang = $collectcfg->{"defaultlanguage"};
567 }
568 &write_line('COLCFG', ["<defaultIndexLanguage name=\"", $default_lang, "\" shortname=\"", $default_lang_short, "\" />"]);
569 }
570
571
572 # do indexSubcollectionList
573 my $default_subcol = "";# make it in sub scope to be used in the concatenation
574 if (defined $buildcfg->{'subcollectionmap'}) {
575 &write_line('COLCFG', ["<indexSubcollectionList>"]);
576 my $subcolmap = {};
577 my @subcollist = ();
578 $first = 1;
579 my $subcolmap_t = $buildcfg->{'subcollectionmap'};
580 foreach my $l (@$subcolmap_t) {
581 my ($k, $v) = $l =~ /^(.*)\-\>(.*)$/;
582 $subcolmap->{$k} = $v;
583 push @subcollist, $k;
584 if ($first) {
585 $default_subcol = $v;
586 $first = 0;
587 }
588 }
589 foreach my $sl (@subcollist) {
590 my $subcol = $subcolmap->{$sl};
591 &write_line('COLCFG', ["<indexSubcollection name=\"", $sl, "\" shortname=\"", $subcol, "\" />"]);
592 }
593
594 &write_line('COLCFG', ["</indexSubcollectionList>"]);
595 &write_line('COLCFG', ["<defaultIndexSubcollection shortname=\"", $default_subcol, "\" />"]);
596 }
597
598 # close off search service
599 &write_line('COLCFG', ["</serviceRack>"]);
600
601 # do the retrieve service
602 &write_line('COLCFG', ["<serviceRack name=\"GS2", $service_type, "Retrieve\">"]);
603
604 # do default index
605 if (defined $buildcfg->{"languagemap"}) {
606 &write_line('COLCFG', ["<defaultIndexLanguage shortname=\"", $default_lang, "\" />"]);
607 }
608 if (defined $buildcfg->{'subcollectionmap'}) {
609 &write_line('COLCFG', ["<defaultIndexSubcollection shortname=\"", $default_subcol, "\" />"]);
610 }
611 if ($buildtype eq "mg") {
612 &write_line('COLCFG', ["<defaultIndex shortname=\"", $defaultindex, "\" />"]);
613 }
614
615 if (defined $buildcfg->{'indexstem'}) {
616 my $indexstem = $buildcfg->{'indexstem'};
617 &write_line('COLCFG', ["<indexStem name=\"", $indexstem, "\" />"]);
618 }
619 if ($buildtype eq "mgpp" || $buildtype eq "lucene") {
620 &write_line('COLCFG', ["<defaultLevel shortname=\"", $default_retrieve_level, "\" />"]);
621 }
622 &write_line('COLCFG', ["</serviceRack>"]);
623
624 # do the browse service
625 my $count = 1;
626 my $phind = 0;
627 my $started_classifiers = 0;
628
629 my $classifiers = $collectcfg->{"classify"};
630 foreach my $cl (@$classifiers) {
631 my $name = "CL$count";
632 $count++;
633 my ($classname) = @$cl[0];
634 if ($classname =~ /^phind$/i) {
635 $phind=1;
636 #should add it into coll config classifiers
637 next;
638 }
639
640 if (not $started_classifiers) {
641 &write_line('COLCFG', ["<serviceRack name=\"GS2Browse\">"]);
642 if (defined $buildcfg->{'indexstem'}) {
643 my $indexstem = $buildcfg->{'indexstem'};
644 &write_line('COLCFG', ["<indexStem name=\"", $indexstem, "\" />"]);
645 }
646 &write_line('COLCFG', ["<classifierList>"]);
647 $started_classifiers = 1;
648 }
649 my $content = ''; #use buttonname first, then metadata
650 if ($classname eq "DateList") {
651 $content = "Date";
652 } else {
653 for (my $j=0; $j<scalar(@$cl); $j++) {
654 my $arg = @$cl[$j];
655 if ($arg eq "-buttonname"){
656 $content = @$cl[$j+1];
657 last;
658 } elsif ($arg eq "-metadata") {
659 $content = @$cl[$j+1];
660 }
661
662 }
663 }
664 &write_line('COLCFG', ["<classifier name=\"", $name, "\" content=\"", $content, "\" />"]);
665 }
666 if ($started_classifiers) {
667 # end the classifiers
668 &write_line('COLCFG', ["</classifierList>"]);
669 # close off the Browse service
670 &write_line('COLCFG', ["</serviceRack>"]);
671 }
672
673 # the phind classifier is a separate service
674 if ($phind) {
675 # if phind classifier
676 &write_line('COLCFG', ["<serviceRack name=\"PhindPhraseBrowse\" />"]);
677 }
678
679 &write_line('COLCFG', ["</serviceRackList>"]);
680 &write_line('COLCFG', ["</buildConfig>"]);
681
682 close (COLCFG);
683 }
684
685
686#########################################################
687
6881;
Note: See TracBrowser for help on using the repository browser.