Changeset 21453
- Timestamp:
- 2010-01-14T16:08:59+13:00 (14 years ago)
- Location:
- main/trunk/greenstone2/runtime-src/src/colservr
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone2/runtime-src/src/colservr/collectset.cpp
r21415 r21453 251 251 } 252 252 253 bool collectset::collection_is_collect_group (const text_t& collect_dir) 254 { 255 text_t is_collect_group_str = "false"; 256 text_t collect_cfg = filename_cat(collect_dir, "etc", "collect.cfg"); 257 258 if (file_exists(collect_cfg)) { 259 char *collect_cfgc = collect_cfg.getcstr(); 260 ifstream confin(collect_cfgc); 261 262 if (confin) { 263 text_tarray cfgline; 264 265 while (read_cfg_line(confin, cfgline) >= 0) { 266 if (cfgline.size() == 2) { 267 text_t key = cfgline[0]; 268 cfgline.erase(cfgline.begin()); 269 if (key == "collectgroup") { 270 is_collect_group_str = cfgline[0]; 271 break; 272 } 273 } 274 } 275 276 confin.close(); 277 } 278 279 delete []collect_cfgc; 280 } 281 282 bool is_collect_group = (is_collect_group_str == "true") ? true : false; 283 284 return is_collect_group; 285 } 286 287 253 288 // add_collection sets up the collectionserver and calls 254 289 // add_collectserver … … 257 292 const text_t& collecthome) 258 293 { 259 260 this->remove_collection(collection);261 262 294 // read config file to see if built with mg, mgpp, or lucene 263 295 text_t buildtype = "mg"; // mg is default 264 296 text_t infodbtype = "gdbm"; // gdbm is default 265 297 298 this->remove_collection(collection); 299 266 300 collectserver *cserver = NULL; 267 268 text_tarray cfgline;269 text_t key;270 301 271 302 text_t build_cfg = filename_cat(collecthome, collection, "index", "build.cfg"); … … 275 306 276 307 if (confin) { 308 text_tarray cfgline; 309 277 310 while (read_cfg_line(confin, cfgline) >= 0) { 278 311 if (cfgline.size() == 2) { 279 key = cfgline[0];312 text_t key = cfgline[0]; 280 313 cfgline.erase(cfgline.begin()); 281 314 if (key == "buildtype") { … … 407 440 else { 408 441 // see if it is a collectgroup col 409 410 411 // This routine essentially exists twice in the code now (see add_collection_group) 412 // factor out as support routine 413 414 text_t collect_cfg = filename_cat(collecthome, collection, "etc", "collect.cfg"); 415 if (file_exists (collect_cfg)) { 416 char *collect_cfgc = collect_cfg.getcstr(); 417 ifstream confin(collect_cfgc); 418 419 text_t is_collect_group = "false"; 420 421 if (confin) { 422 while (read_cfg_line(confin, cfgline) >= 0) { 423 if (cfgline.size() == 2) { 424 key = cfgline[0]; 425 426 cfgline.erase(cfgline.begin()); 427 if (key == "collectgroup") { 428 is_collect_group = cfgline[0]; 429 } 430 } 431 } 432 confin.close(); 433 } 434 delete []collect_cfgc; 435 436 if (is_collect_group != "true") { 437 // an unbuilt leaf collection 438 return; 439 } 440 441 // by this point we know we will need a cserver 442 cserver = new collectserver(); 443 444 } 445 else { 446 // no collect.cfg => filter it out from list of collections added 447 return; 448 } 449 } 450 451 // inform collection server and everything it contains about its 452 // collection name 453 cserver->configure ("collection", collection); 454 cserver->configure ("gsdlhome", gsdlhome); 455 cserver->configure ("collecthome", collecthome); 456 cservers.addcollectserver (cserver); 442 text_t this_collect_dir = filename_cat(collecthome, collection); 443 if (collection_is_collect_group(this_collect_dir)) { 444 // by this point we know we will need a cserver 445 cserver = new collectserver(); 446 } 447 // else not a collect group, or there was no collect.cfg 448 // => leave cserver as NULL so it will not be added into cservers 449 } 450 451 if (cserver != NULL) { 452 // inform collection server and everything it contains about its 453 // collection name 454 cserver->configure ("collection", collection); 455 cserver->configure ("gsdlhome", gsdlhome); 456 cserver->configure ("collecthome", collecthome); 457 cservers.addcollectserver (cserver); 458 } 457 459 } 458 460 … … 488 490 489 491 // need to read collect.cfg for 'collectgroup' as class hasn't been initialised through 'init' yet 490 text_t is_collect_group; 491 text_tarray cfgline; 492 text_t key; 493 text_t collect_cfg = filename_cat(collect_group_dir, "etc", "collect.cfg"); 494 char *collect_cfgc = collect_cfg.getcstr(); 495 ifstream confin(collect_cfgc); 496 497 if (confin) { 498 while (read_cfg_line(confin, cfgline) >= 0) { 499 if (cfgline.size() == 2) { 500 key = cfgline[0]; 501 cfgline.erase(cfgline.begin()); 502 if (key == "collectgroup") { 503 is_collect_group = cfgline[0]; 504 break; 505 } 506 } 507 } 508 confin.close(); 509 } 510 delete []collect_cfgc; 511 512 if (is_collect_group == "true") { 492 if (collection_is_collect_group(collect_group_dir)) { 513 493 if (read_dir (collect_group_dir, group)) { 514 494 -
main/trunk/greenstone2/runtime-src/src/colservr/collectset.h
r21324 r21453 87 87 return cservers.getcollectserver(collection); 88 88 } 89 90 protected: 91 bool collection_is_collect_group (const text_t& collect_dir); 89 92 }; 90 93
Note:
See TracChangeset
for help on using the changeset viewer.