Changeset 16312 for gsdl/trunk/src/colservr/collectset.cpp
- Timestamp:
- 2008-07-09T13:19:53+12:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gsdl/trunk/src/colservr/collectset.cpp
r15759 r16312 47 47 #endif 48 48 49 50 collectset::collectset (text_t &gsdlhome) { 49 collectset::collectset (text_t& gsdlhome, text_t& collecthome) 50 { 51 // gsdlhome and collecthome will be set as a result of calling this function 52 // collecthome will default to "<gsdlhome>/collect" if not explicitly 53 // specified in config file 51 54 52 55 text_tarray collections; 53 text_t collectdir;54 56 55 57 // get gsdlhome (if we fail the error will be picked up later -- in 56 58 // cgiwrapper) 57 59 58 if (site_cfg_read (gsdlhome, httpdomain, httpprefix)) {60 if (site_cfg_read (gsdlhome, collecthome, httpdomain, httpprefix)) { 59 61 if (!gsdlhome.empty() && directory_exists(gsdlhome)) { 60 collectdir = filename_cat (gsdlhome, "collect"); 61 if (read_dir (collectdir, collections)) { 62 if (read_dir (collecthome, collections)) { 62 63 63 64 text_tarray::const_iterator thiscol = collections.begin(); … … 71 72 } 72 73 73 this->add_collection (*thiscol, gsdlhome );74 this->add_collection (*thiscol, gsdlhome, collecthome); 74 75 75 76 ++thiscol; 76 77 } 77 78 78 this->add_all_collection_groups(gsdlhome );79 this->add_all_collection_groups(gsdlhome, collecthome); 79 80 } 80 81 } … … 112 113 bool failed_build_cfg = false; 113 114 if (!build_cfg_read (*((*here).second.c), configinfo.gsdlhome, 114 configinfo.collect ion)) {115 configinfo.collecthome, configinfo.collection)) { 115 116 failed_build_cfg = true; 116 117 117 118 outconvertclass text_t2ascii; 118 119 logout << text_t2ascii 119 << "Warning: couldn't read build.cfg file for collection \"" //**** 120 << configinfo.collection << "\", gsdlhome=\"" 121 << configinfo.gsdlhome << "\"\n"; 120 << "Warning: couldn't read build.cfg file for collection \"" 121 << configinfo.collection << "\"" 122 << " gsdlhome=\"" << configinfo.gsdlhome << "\"\n" 123 << " collecthome=\"" << configinfo.collecthome << "\"\n"; 122 124 } 123 125 124 126 bool failed_collect_cfg = false; 125 127 if (!collect_cfg_read (*((*here).second.c), configinfo.gsdlhome, 126 configinfo.collect ion)) {128 configinfo.collecthome, configinfo.collection)) { 127 129 failed_collect_cfg = true; 128 130 outconvertclass text_t2ascii; 129 131 logout << text_t2ascii 130 132 << "Warning: couldn't read collect.cfg file for collection \"" 131 << configinfo.collection << "\", gsdlhome=\"" 132 << configinfo.gsdlhome << "\"\n"; 133 << configinfo.collection << "\"" 134 << " gsdlhome=\"" << configinfo.gsdlhome << "\"\n" 135 << " collecthome=\"" << configinfo.collecthome << "\"\n"; 133 136 } 134 137 … … 163 166 164 167 165 void collectset::add_all_collections(const text_t &gsdlhome) { 166 168 void collectset::add_all_collections(const text_t &gsdlhome, 169 const text_t& collecthome) 170 { 167 171 text_tarray collections; 168 text_t collectdir = filename_cat(gsdlhome, "collect"); 169 if (read_dir(collect dir, collections)) {172 173 if (read_dir(collecthome, collections)) { 170 174 171 175 text_tarray::const_iterator thiscol = collections.begin(); … … 181 185 182 186 // create collection server for this collection 183 this->add_collection (*thiscol, gsdlhome );187 this->add_collection (*thiscol, gsdlhome, collecthome); 184 188 185 189 ++thiscol; 186 190 } 187 191 188 this->add_all_collection_groups(gsdlhome );192 this->add_all_collection_groups(gsdlhome,collecthome); 189 193 } 190 194 } … … 192 196 // add_collection sets up the collectionserver and calls 193 197 // add_collectserver 194 void collectset::add_collection (const text_t &collection, 195 const text_t &gsdlhome) { 198 void collectset::add_collection (const text_t& collection, 199 const text_t& gsdlhome, 200 const text_t& collecthome) 201 { 196 202 197 203 this->remove_collection(collection); … … 203 209 text_tarray cfgline; 204 210 text_t key; 205 text_t build_cfg = filename_cat(gsdlhome, "collect", collection, "index", "build.cfg"); 211 212 text_t build_cfg = filename_cat(collecthome, collection, "index", "build.cfg"); 206 213 char *build_cfgc = build_cfg.getcstr(); 207 214 ifstream confin(build_cfgc); … … 289 296 else if (buildtype == "lucene") { 290 297 lucenesearch = new lucenesearchclass(); 291 lucenesearch->set_gsdlhome(gsdlhome); 298 lucenesearch->set_gsdlhome(gsdlhome); 292 299 293 300 // add a query filter … … 308 315 cserver->configure ("collection", collection); 309 316 cserver->configure ("gsdlhome", gsdlhome); 310 317 cserver->configure ("collecthome", collecthome); 311 318 cservers.addcollectserver (cserver); 312 319 } … … 333 340 334 341 void collectset::add_collection_group(const text_t& collection, 335 const text_t& gsdlhome) 342 const text_t& gsdlhome, 343 const text_t& collecthome) 336 344 { 337 345 text_tarray group; 338 text_t collect_group_dir = filename_cat (gsdlhome, "collect", collection); 346 347 text_t collect_group_dir = filename_cat (collecthome, collection); 339 348 340 349 // need to read collect.cfg for 'collectgroup' as class hasn't been initialised through 'init' yet … … 342 351 text_tarray cfgline; 343 352 text_t key; 344 text_t build_cfg = filename_cat( gsdlhome, "collect", collection, "etc", "collect.cfg");353 text_t build_cfg = filename_cat(collect_group_dir, "etc", "collect.cfg"); 345 354 char *collect_cfgc = build_cfg.getcstr(); 346 355 ifstream confin(collect_cfgc); … … 375 384 } 376 385 377 this->add_collection (collection + "/" + *thiscol, gsdlhome); 386 text_t group_col = filename_cat(collection,*thiscol); 387 this->add_collection (group_col, gsdlhome, collecthome); 378 388 379 389 ++thiscol; … … 383 393 } 384 394 385 void collectset::add_all_collection_groups (const text_t& gsdlhome) 395 void collectset::add_all_collection_groups (const text_t& gsdlhome, 396 const text_t& collecthome) 386 397 387 398 { … … 391 402 while (here != end) { 392 403 text_t collection = (*here).second.c->get_collection_name(); 393 this->add_collection_group(collection,gsdlhome );404 this->add_collection_group(collection,gsdlhome,collecthome); 394 405 395 406 ++here; … … 443 454 void collectset::configure(const text_t &key, const text_tarray &cfgline) 444 455 { 445 if ( key == "collection" || key == "collectdir") return;456 if ((key == "collection") || (key == "collectdir")) return; 446 457 447 458 collectservermapclass::iterator here = cservers.begin(); … … 453 464 if (key == "collectinfo") { 454 465 if ((*here).first == cfgline[0]) { 455 (*here).second.c->configure ("gsdlhome", cfgline[1]); 456 (*here).second.c->configure ("gdbmhome", cfgline[2]); 466 if (cfgline.size()==3) { 467 (*here).second.c->configure ("gsdlhome", cfgline[1]); 468 (*here).second.c->configure ("gdbmhome", cfgline[2]); 469 } 470 else { 471 (*here).second.c->configure ("gsdlhome", cfgline[1]); 472 (*here).second.c->configure ("collecthome", cfgline[2]); 473 (*here).second.c->configure ("gdbmhome", cfgline[3]); 474 } 457 475 } 458 476 } else { … … 479 497 } 480 498 } 499
Note:
See TracChangeset
for help on using the changeset viewer.