Changeset 18903

Show
Ignore:
Timestamp:
08.04.2009 10:47:40 (10 years ago)
Author:
kjdon
Message:

check the existence of collect.cfg to see if a collection name is valid or not, then don't advertise it if not.

Location:
gsdl/trunk/runtime-src/src/oaiservr
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • gsdl/trunk/runtime-src/src/oaiservr/oaiconfig.cpp

    r18892 r18903  
    4747  // parameter, read in all the collection's individual configurations 
    4848  if (gsdlcollect == "") { 
    49     text_tarray::iterator here = this->collectList.begin(); 
    50     text_tarray::iterator end  = this->collectList.end(); 
    51     while (here != end) {        
    52       this->configureCollection(gsdlhome, *here); 
    53       ++here; 
    54     } 
     49    text_tarray::iterator start = this->collectList.begin(); 
     50    text_tarray::iterator here  = this->collectList.end()-1; 
     51    while (here != start) {      
     52      if (!this->configureCollection(gsdlhome, *here)) { 
     53    this->collectList.erase(here); 
     54      } 
     55      --here; 
     56    } 
     57    // and do the first one 
     58    if (!this->configureCollection(gsdlhome, *here)) { 
     59      this->collectList.erase(here); 
     60    } 
     61     
    5562  } 
    5663  else { 
     64    // what do we do if this fails? 
    5765    this->configureCollection(gsdlhome, gsdlcollect); 
    5866  } 
     
    8189} 
    8290 
    83 void oaiconfig::configureCollection(const text_t &gsdlhome, const text_t &gsdlcollect) 
     91bool oaiconfig::configureCollection(const text_t &gsdlhome, const text_t &gsdlcollect) 
    8492{ 
    8593  text_t cnfgfile = filename_cat(gsdlhome, "collect", gsdlcollect, "etc", "collect.cfg"); 
     94  if (!file_exists(cnfgfile)) { 
     95    return false; 
     96  } 
    8697  this->collection = gsdlcollect; 
    8798  this->read_configfile(cnfgfile); 
    88 } 
    89  
     99 
     100  return true; 
     101} 
    90102void oaiconfig::configure (const text_t &key, const text_tarray &cfgline) 
    91103{ 
  • gsdl/trunk/runtime-src/src/oaiservr/oaiconfig.h

    r18891 r18903  
    3737  int           resumeAfter(); 
    3838 private: 
    39   void configureCollection(const text_t &gsdlhome, const text_t &collection); 
     39  bool configureCollection(const text_t &gsdlhome, const text_t &collection); 
    4040   
    4141  text_tarray collectList;  // The list of collections to be taken in hand