source: gsdl/branches/protos-branch/perllib/cfgread4gs3.pm@ 19079

Last change on this file since 19079 was 14184, checked in by xiao, 17 years ago

change the default retrieve level to follow the text level

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