Changeset 16312


Ignore:
Timestamp:
2008-07-09T13:19:53+12:00 (16 years ago)
Author:
davidb
Message:

Introduction of 'collecthome' which parallels 'gsdlhome' to allow the toplevel collect folder to be outside of the gsdlhome area

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gsdl/trunk/src/colservr/collectset.cpp

    r15759 r16312  
    4747#endif
    4848
    49 
    50 collectset::collectset (text_t &gsdlhome) {
     49collectset::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
    5154
    5255  text_tarray collections;
    53   text_t      collectdir;
    5456
    5557  // get gsdlhome (if we fail the error will be picked up later -- in
    5658  // cgiwrapper)
    5759
    58   if (site_cfg_read (gsdlhome, httpdomain, httpprefix)) {
     60  if (site_cfg_read (gsdlhome, collecthome, httpdomain, httpprefix)) {
    5961    if (!gsdlhome.empty() && directory_exists(gsdlhome)) {
    60       collectdir = filename_cat (gsdlhome, "collect");
    61       if (read_dir (collectdir, collections)) {
     62      if (read_dir (collecthome, collections)) {
    6263   
    6364    text_tarray::const_iterator thiscol = collections.begin();
     
    7172      }
    7273
    73       this->add_collection (*thiscol, gsdlhome);
     74      this->add_collection (*thiscol, gsdlhome, collecthome);
    7475
    7576      ++thiscol;
    7677    }
    7778
    78     this->add_all_collection_groups(gsdlhome);
     79    this->add_all_collection_groups(gsdlhome, collecthome);
    7980      }
    8081    }
     
    112113      bool failed_build_cfg = false;
    113114      if (!build_cfg_read (*((*here).second.c), configinfo.gsdlhome,
    114                configinfo.collection)) {
     115               configinfo.collecthome, configinfo.collection)) {
    115116    failed_build_cfg = true;
    116117
    117118    outconvertclass text_t2ascii;
    118119    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";
    122124      }
    123125
    124126      bool failed_collect_cfg = false;
    125127      if (!collect_cfg_read (*((*here).second.c), configinfo.gsdlhome,
    126                  configinfo.collection)) {
     128                 configinfo.collecthome, configinfo.collection)) {
    127129    failed_collect_cfg = true;
    128130    outconvertclass text_t2ascii;
    129131    logout << text_t2ascii
    130132           << "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";
    133136      }
    134137
     
    163166
    164167
    165 void collectset::add_all_collections(const text_t &gsdlhome) {
    166 
     168void collectset::add_all_collections(const text_t &gsdlhome,
     169                     const text_t& collecthome)
     170{
    167171  text_tarray collections;
    168   text_t collectdir = filename_cat(gsdlhome, "collect");
    169   if (read_dir(collectdir, collections)) {
     172
     173  if (read_dir(collecthome, collections)) {
    170174
    171175    text_tarray::const_iterator thiscol = collections.begin();
     
    181185   
    182186      // create collection server for this collection
    183       this->add_collection (*thiscol, gsdlhome);
     187      this->add_collection (*thiscol, gsdlhome, collecthome);
    184188   
    185189      ++thiscol;
    186190    }
    187191
    188     this->add_all_collection_groups(gsdlhome);
     192    this->add_all_collection_groups(gsdlhome,collecthome);
    189193  }
    190194}
     
    192196// add_collection sets up the collectionserver and calls
    193197// add_collectserver
    194 void collectset::add_collection (const text_t &collection,
    195                  const text_t &gsdlhome) {
     198void collectset::add_collection (const text_t& collection,
     199                 const text_t& gsdlhome,
     200                 const text_t& collecthome)
     201{
    196202
    197203  this->remove_collection(collection);
     
    203209  text_tarray cfgline;
    204210  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");
    206213  char *build_cfgc = build_cfg.getcstr();
    207214  ifstream confin(build_cfgc);
     
    289296  else if (buildtype == "lucene") {
    290297    lucenesearch = new lucenesearchclass();
    291     lucenesearch->set_gsdlhome(gsdlhome);
     298    lucenesearch->set_gsdlhome(gsdlhome); 
    292299
    293300    // add a query filter
     
    308315  cserver->configure ("collection", collection);
    309316  cserver->configure ("gsdlhome", gsdlhome);
    310 
     317  cserver->configure ("collecthome", collecthome);
    311318  cservers.addcollectserver (cserver);
    312319}
     
    333340
    334341void collectset::add_collection_group(const text_t& collection,
    335                       const text_t& gsdlhome)
     342                      const text_t& gsdlhome,
     343                      const text_t& collecthome)
    336344{
    337345  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);
    339348
    340349  // need to read collect.cfg for 'collectgroup' as class hasn't been initialised through 'init' yet
     
    342351  text_tarray cfgline;
    343352  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");
    345354  char *collect_cfgc = build_cfg.getcstr();
    346355  ifstream confin(collect_cfgc);
     
    375384    }
    376385   
    377     this->add_collection (collection + "/" + *thiscol, gsdlhome);
     386    text_t group_col = filename_cat(collection,*thiscol);
     387    this->add_collection (group_col, gsdlhome, collecthome);
    378388   
    379389    ++thiscol;
     
    383393}
    384394
    385 void collectset::add_all_collection_groups (const text_t& gsdlhome)
     395void collectset::add_all_collection_groups (const text_t& gsdlhome,
     396                        const text_t& collecthome)
    386397
    387398{
     
    391402  while (here != end) {
    392403    text_t collection = (*here).second.c->get_collection_name();
    393     this->add_collection_group(collection,gsdlhome);
     404    this->add_collection_group(collection,gsdlhome,collecthome);
    394405
    395406    ++here;
     
    443454void collectset::configure(const text_t &key, const text_tarray &cfgline)
    444455{
    445   if (key == "collection" || key == "collectdir") return;
     456  if ((key == "collection") || (key == "collectdir")) return;
    446457
    447458  collectservermapclass::iterator here = cservers.begin();
     
    453464      if (key == "collectinfo") {
    454465    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      }
    457475    }
    458476      } else {
     
    479497  }
    480498}
     499
Note: See TracChangeset for help on using the changeset viewer.