Changeset 1270


Ignore:
Timestamp:
2000-07-06T09:49:36+12:00 (24 years ago)
Author:
sjboddie
Message:

Receptionist now caches collection information to avoid making multiple
get_collectinfo calls to collection server

Location:
trunk/gsdl
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/lib/cfgread.cpp

    r1076 r1270  
    2828/*
    2929   $Log$
     30   Revision 1.9  2000/07/05 21:49:22  sjboddie
     31   Receptionist now caches collection information to avoid making multiple
     32   get_collectinfo calls to collection server
     33
    3034   Revision 1.8  2000/04/06 19:57:57  cs025
    3135   Correcting a correction - reinstated all lib files due to silly
     
    5660
    5761#include "cfgread.h"
    58 
    59 void collectioninfo_t::clear () {
    60   gsdl_gsdlhome.clear();
    61   gsdl_gdbmhome.clear();
    62 }
    6362
    6463int write_ini_line (ofstream &fileout, const text_t &key, const text_t value) {
  • trunk/gsdl/lib/cfgread.h

    r1076 r1270  
    4141#endif
    4242
    43 struct collectioninfo_t {
    44   void clear ();
    45   collectioninfo_t () {clear();}
    46 
    47   text_t gsdl_gsdlhome;
    48   text_t gsdl_gdbmhome;
    49 };
    50 
    51 typedef map<text_t, collectioninfo_t, lttext_t> colinfo_tmap;
    52 
    5343// return 0 on success, -1 on failure
    5444int write_ini_line (ofstream &fileout, const text_t &key, const text_t value);
  • trunk/gsdl/src/recpt/buildaction.cpp

    r1177 r1270  
    102102  // make sure we know about a receptionist
    103103  if (recpt == NULL) {
    104     logout << "The page action does not contain information\n"
     104    logout << "The build action does not contain information\n"
    105105           << "about any receptionists. The method set_receptionist\n"
    106106           << "was probably not called from the module which instantiated\n"
    107            << "this page action.\n";
     107           << "this build action.\n";
    108108    return;
    109109  }
     
    146146    while (collist_here != collist_end) {
    147147
    148       ColInfoResponse_t cinfo;
    149       (*rprotolist_here).p->get_collectinfo (*collist_here, cinfo, err, logout);
    150       if (err == noError) {
     148      ColInfoResponse_t *cinfo = recpt->get_collectinfo_ptr ((*rprotolist_here).p, *collist_here, logout);
     149      if (cinfo != NULL) {
    151150        text_t collectionname = *collist_here;
    152         if (!cinfo.collectionmeta["collectionname"].empty())
     151        if (!cinfo->collectionmeta["collectionname"].empty())
    153152          {
    154153        // get collection name from the collection cfg file
    155         collectionname = cinfo.collectionmeta["collectionname"];
     154        collectionname = cinfo->collectionmeta["collectionname"];
    156155          }
    157156        else
     
    206205            || (args["bc1dirname"]==*collist_here))
    207206          {
    208             disp.setmacro("bcargingsdlarea","build",cinfo.building["ingsdlarea"]);
    209             disp.setmacro("bcargcopydir","build",cinfo.building["copydir"]);
     207            disp.setmacro("bcargingsdlarea","build",cinfo->building["ingsdlarea"]);
     208            disp.setmacro("bcargcopydir","build",cinfo->building["copydir"]);
    210209           
    211             if (cinfo.buildDate==0) // not built
     210            if (cinfo->buildDate==0) // not built
    212211              {
    213212            // assume that's because this is the first build ever for the collection
  • trunk/gsdl/src/recpt/cgiwrapper.cpp

    r1255 r1270  
    2828/*
    2929   $Log$
     30   Revision 1.30  2000/07/05 21:49:31  sjboddie
     31   Receptionist now caches collection information to avoid making multiple
     32   get_collectinfo calls to collection server
     33
    3034   Revision 1.29  2000/06/29 03:57:14  sjboddie
    3135   Now append to error log (errout.txt) instead of overwriting it each time
     
    515519      cout << text_t2ascii << outspaces;
    516520
    517       ColInfoResponse_t cinfo;
    518       (*rprotolist_here).p->get_collectinfo (*collist_here, cinfo, err, cerr);
    519       if (err == noError) {
    520         if (cinfo.isPublic) cout << "public ";
     521      ColInfoResponse_t *cinfo = recpt.get_collectinfo_ptr ((*rprotolist_here).p, *collist_here, cerr);
     522      if (cinfo != NULL) {
     523        if (cinfo->isPublic) cout << "public ";
    521524        else cout << "private";
    522525
    523         if (cinfo.buildDate > 0) cout << "   running    ";
     526        if (cinfo->buildDate > 0) cout << "   running    ";
    524527        else cout << "   not running";
    525528      }
  • trunk/gsdl/src/recpt/documentaction.cpp

    r1148 r1270  
    2828/*
    2929   $Log$
     30   Revision 1.39  2000/07/05 21:49:31  sjboddie
     31   Receptionist now caches collection information to avoid making multiple
     32   get_collectinfo calls to collection server
     33
    3034   Revision 1.38  2000/05/04 05:18:46  sjboddie
    3135   attempting to get end-user collection building to work under windows
     
    183187
    184188documentaction::documentaction () {
     189  recpt = NULL;
     190
    185191
    186192  // this action uses cgi variables "a", "d", "cl",
     
    500506  if (collectproto == NULL) return;
    501507 
     508  if (recpt == NULL) {
     509    logout << "ERROR (documentaction::define_external_macros): This action does not contain\n"
     510       << "      information about any receptionists. The method set_receptionist was\n"
     511       << "      probably not called from the module which instantiated this action.\n";
     512    return;
     513  }
     514
    502515  outconvertclass text_t2ascii;
    503516  comerror_t err;
     
    506519  text_tset metadata;
    507520
    508 
    509   // get info on current collection and load up formatinfo
    510   // I'd prefer not to do this here as we're getting
    511   // collection info every time (and probably also getting
    512   // it in other places some of the time) - One day I'll
    513   // fix it ... maybe - Stefan.
    514   ColInfoResponse_t cinfo;
    515   collectproto->get_collectinfo (collection, cinfo, err, logout);
    516   load_formatinfo (cinfo.format, args.getintarg("gt"));
     521  ColInfoResponse_t *cinfo = recpt->get_collectinfo_ptr (collectproto, collection, logout);
     522  if (cinfo == NULL) {
     523    logout << "ERROR (documentaction::define_external_macros): get_collectinfo_ptr returned NULL\n";
     524    return;
     525  }
     526  load_formatinfo (cinfo->format, args.getintarg("gt"));
    517527
    518528  if (formatinfo.DocumentUseHTML) {
     
    526536      disp.setmacro ("gsdltop", "Global", "documenttop");
    527537    }
    528     text_tmap::iterator it = cinfo.format.find ("homepage");
    529     if (it != cinfo.format.end()) {
     538    text_tmap::iterator it = cinfo->format.find ("homepage");
     539    if (it != cinfo->format.end()) {
    530540      text_t httppagehome;
    531541      if (get_link (args, protos, (*it).second, httppagehome, logout))
     
    11011111  textout << outconvert << disp << buffer;
    11021112}
    1103 
    1104 
    1105 
    1106 
    1107 
    1108 
    1109 
    1110 
    1111 
    1112 
    1113 
  • trunk/gsdl/src/recpt/documentaction.h

    r1079 r1270  
    7979  virtual ~documentaction ();
    8080
     81  void set_receptionist (receptionist *therecpt) {recpt=therecpt;}
     82
    8183  text_t get_action_name () {return "d";}
    8284
  • trunk/gsdl/src/recpt/librarymain.cpp

    r1233 r1270  
    2828/*
    2929   $Log$
     30   Revision 1.28  2000/07/05 21:49:32  sjboddie
     31   Receptionist now caches collection information to avoid making multiple
     32   get_collectinfo calls to collection server
     33
    3034   Revision 1.27  2000/06/23 03:21:39  sjboddie
    3135   Created converter classes for simple 8 bit encodings that use a
     
    251255
    252256  pageaction apageaction;
     257  apageaction.set_receptionist (&recpt);
    253258  recpt.add_action (&apageaction);
    254259
     
    257262
    258263  queryaction aqueryaction;
     264  aqueryaction.set_receptionist (&recpt);
    259265  recpt.add_action (&aqueryaction);
    260266
    261267  documentaction adocumentaction;
     268  adocumentaction.set_receptionist (&recpt);
    262269  recpt.add_action (&adocumentaction);
    263270
  • trunk/gsdl/src/recpt/pageaction.cpp

    r1247 r1270  
    2828/*
    2929   $Log$
     30   Revision 1.33  2000/07/05 21:49:33  sjboddie
     31   Receptionist now caches collection information to avoid making multiple
     32   get_collectinfo calls to collection server
     33
    3034   Revision 1.32  2000/06/27 23:02:40  sjboddie
    3135   Tidied up the way collections are displayed on 'standard' homepage.
     
    220224    while (collist_here != collist_end) {
    221225     
    222       ColInfoResponse_t cinfo;
    223       (*rprotolist_here).p->get_collectinfo (*collist_here, cinfo, err, logout);
     226      ColInfoResponse_t *cinfo = recpt->get_collectinfo_ptr ((*rprotolist_here).p, *collist_here, logout);
    224227     
    225       if (err == noError) {
    226         if (cinfo.isPublic && (cinfo.buildDate > 0)) {
     228      if (cinfo != NULL) {
     229        if (cinfo->isPublic && (cinfo->buildDate > 0)) {
    227230         
    228231          FilterResponse_t response;
     
    258261        link = "<a href=\"_gwcgi_?a=p&p=about&l=ar&nw=u&c=" + *collist_here + "\">";
    259262
    260           if (!cinfo.receptionist.empty())
    261         link = "<a href=\"" + cinfo.receptionist + "\">";
     263          if (!cinfo->receptionist.empty())
     264        link = "<a href=\"" + cinfo->receptionist + "\">";
    262265         
    263266          homeextra += "<td>" + link + collectionname + "</a></td>\n";
     
    324327
    325328 
     329  if (recpt == NULL) {
     330    logout << "ERROR (pageaction::define_internal_macros): This action does not contain\n"
     331       << "      information about any receptionists. The method set_receptionist was\n"
     332       << "      probably not called from the module which instantiated this action.\n";
     333    return;
     334  }
     335
    326336  text_t &arg_p = args["p"];
    327337  text_t &arg_c = args["c"];
    328   ColInfoResponse_t cinfo;
    329   comerror_t err;
     338  ColInfoResponse_t *cinfo = NULL;
    330339
    331340  recptproto* collectproto = protos->getrecptproto (arg_c, logout);
    332341  if (collectproto != NULL) {
    333     collectproto->get_collectinfo (arg_c, cinfo, err, logout);
    334 
    335     disp.setmacro ("numdocs", "Global", cinfo.numDocs);
     342    cinfo = recpt->get_collectinfo_ptr (collectproto, arg_c, logout);
     343
     344    disp.setmacro ("numdocs", "Global", cinfo->numDocs);
    336345    unsigned long current_time = time(NULL);
    337     unsigned long builddate = (current_time - cinfo.buildDate) / 86400;
     346    unsigned long builddate = (current_time - cinfo->buildDate) / 86400;
    338347    disp.setmacro ("builddate", "Global", builddate);
    339348  }
     
    345354    // _collectionoption_
    346355
    347     if (args["ccs"] == "1" && collectproto != NULL && (cinfo.ccsCols.size() > 1)) {
     356    if (args["ccs"] == "1" && collectproto != NULL && (cinfo->ccsCols.size() > 1)) {
    348357      text_t collectionoption = "_textcollectionoption_";
    349       text_tarray::const_iterator col_here = cinfo.ccsCols.begin();
    350       text_tarray::const_iterator col_end = cinfo.ccsCols.end();
     358      text_tarray::const_iterator col_here = cinfo->ccsCols.begin();
     359      text_tarray::const_iterator col_end = cinfo->ccsCols.end();
    351360      int count = 0;
    352361      while (col_here != col_end) {
    353362    text_t colname;
    354363    if (*col_here == arg_c) {
    355         colname = cinfo.collectionmeta["collectionname"];
     364        colname = cinfo->collectionmeta["collectionname"];
    356365    } else {
    357       ColInfoResponse_t this_cinfo;
    358       collectproto->get_collectinfo (*col_here, this_cinfo, err, logout);
    359       if (err != noError) {col_here ++; continue;}
    360       colname = this_cinfo.collectionmeta["collectionname"];
     366      ColInfoResponse_t *this_cinfo = recpt->get_collectinfo_ptr (collectproto, *col_here, logout);
     367      if (this_cinfo == NULL) {col_here ++; continue;}
     368      colname = this_cinfo->collectionmeta["collectionname"];
    361369    }
    362370
     
    374382    // _htmloptions_
    375383   
    376     text_tmap::const_iterator it = cinfo.format.find ("DocumentUseHTML");
    377     if ((it != cinfo.format.end()) && ((*it).second == "true")) {
     384    text_tmap::const_iterator it = cinfo->format.find ("DocumentUseHTML");
     385    if ((it != cinfo->format.end()) && ((*it).second == "true")) {
    378386      disp.setmacro ("htmloptions", "preferences", "_htmloptionson_");
    379387
     
    381389      // _PreferenceDocsFromWeb_
    382390
    383       it = cinfo.format.find ("PreferenceDocsFromWeb");
    384       if ((it == cinfo.format.end()) || ((*it).second == "true"))
     391      it = cinfo->format.find ("PreferenceDocsFromWeb");
     392      if ((it == cinfo->format.end()) || ((*it).second == "true"))
    385393    disp.setmacro ("PreferenceDocsFromWeb", "preferences", "1");
    386394    }
     
    407415
    408416    text_t languageoption = "_textlanguage_\n<select name=\"l\" onChange=\"updatel();\">\n";
    409     it = cinfo.format.find ("PreferenceLanguages");
    410     if ((it != cinfo.format.end()) && (!(*it).second.empty())) {
     417    it = cinfo->format.find ("PreferenceLanguages");
     418    if ((it != cinfo->format.end()) && (!(*it).second.empty())) {
    411419      text_tset pref_langs;
    412420      splitchar ((*it).second.begin(), (*it).second.end(), '|', pref_langs);
     
    479487         
    480488      // if HTML collection there's no how to read document text
    481       text_tmap::const_iterator it = cinfo.format.find ("HelpNoDocs");
    482       if ((it != cinfo.format.end()) && ((*it).second == "true")) {
     489      text_tmap::const_iterator it = cinfo->format.find ("HelpNoDocs");
     490      if ((it != cinfo->format.end()) && ((*it).second == "true")) {
    483491    disp.setmacro ("topicreadingdocs", "help", "");
    484492    disp.setmacro ("texthelpreadingdocs", "help", "");
    485493      }
    486       it = cinfo.format.find ("HelpBibDocs");
    487       if ((it != cinfo.format.end()) && ((*it).second == "true")) {
     494      it = cinfo->format.find ("HelpBibDocs");
     495      if ((it != cinfo->format.end()) && ((*it).second == "true")) {
    488496    disp.setmacro ("texthelpreadingdocs", "help", "_bibtexthelpreadingdocs_");
    489497    disp.setmacro ("textreadingdocs", "help", "_bibtextreadingdocs_");
    490498      }
    491       it = cinfo.format.find ("HelpBookDocs");
    492       if ((it != cinfo.format.end()) && ((*it).second == "true")) {
     499      it = cinfo->format.find ("HelpBookDocs");
     500      if ((it != cinfo->format.end()) && ((*it).second == "true")) {
    493501    disp.setmacro ("texthelpreadingdocs", "help", "_booktexthelpreadingdocs_");
    494502    disp.setmacro ("textreadingdocs", "help", "_booktextreadingdocs_");
     
    499507
    500508      // _textsubcollections_
    501       if (args["ccs"] == "1" && (cinfo.ccsCols.size() > 1)) {
    502     text_t textsubcollections = "_textsubcols1_(" + text_t(cinfo.ccsCols.size()) + ")";
    503     text_tarray::const_iterator here = cinfo.ccsCols.begin();
    504     text_tarray::const_iterator end = cinfo.ccsCols.end();
     509      if (args["ccs"] == "1" && (cinfo->ccsCols.size() > 1)) {
     510    text_t textsubcollections = "_textsubcols1_(" + text_t(cinfo->ccsCols.size()) + ")";
     511    text_tarray::const_iterator here = cinfo->ccsCols.begin();
     512    text_tarray::const_iterator end = cinfo->ccsCols.end();
    505513    bool first = true;
    506514    int count = 0;
     
    508516      if (*here == arg_c) {
    509517        if (!first) textsubcollections += "<br>";
    510         textsubcollections += "\n" + cinfo.collectionmeta["collectionname"] + "\n";
     518        textsubcollections += "\n" + cinfo->collectionmeta["collectionname"] + "\n";
    511519      } else {
    512         ColInfoResponse_t this_cinfo;
    513         collectproto->get_collectinfo (*here, this_cinfo, err, logout);
    514         if (err != noError) {here ++; continue;}
     520        ColInfoResponse_t *this_cinfo = recpt->get_collectinfo_ptr (collectproto, *here, logout);
     521        if (this_cinfo == NULL) {here ++; continue;}
    515522        if (!first) textsubcollections += "<br>";
    516         textsubcollections += "\n" + this_cinfo.collectionmeta["collectionname"] + "\n";
     523        textsubcollections += "\n" + this_cinfo->collectionmeta["collectionname"] + "\n";
    517524      }
    518525      count ++;
  • trunk/gsdl/src/recpt/pageaction.h

    r761 r1270  
    4747  virtual ~pageaction ();
    4848
     49  void set_receptionist (receptionist *therecpt) {recpt=therecpt;}
     50
    4951  text_t get_action_name () {return "p";}
    5052
  • trunk/gsdl/src/recpt/queryaction.cpp

    r962 r1270  
    2828/*
    2929   $Log$
     30   Revision 1.37  2000/07/05 21:49:34  sjboddie
     31   Receptionist now caches collection information to avoid making multiple
     32   get_collectinfo calls to collection server
     33
    3034   Revision 1.36  2000/02/21 21:57:48  sjboddie
    3135   actions are now configured with gsdlhome
     
    177181queryaction::queryaction () {
    178182
     183  recpt = NULL;
    179184  num_phrases = 0;
    180185
     
    695700                  ostream &textout, ostream &logout) {
    696701
    697   ColInfoResponse_t cinfo;
     702  ColInfoResponse_t *cinfo = NULL;
    698703  comerror_t err;
    699704  InfoFilterOptionsResponse_t fresponse;
     
    737742    while (collist_here != collist_end) {
    738743     
    739       (*rprotolist_here).p->get_collectinfo (*collist_here, cinfo, err, logout);
     744      cinfo = recpt->get_collectinfo_ptr ((*rprotolist_here).p, *collist_here, logout);
    740745      //      if (err == noError && cinfo.isPublic && (cinfo.buildDate > 0)) {
    741       if (err == noError && (cinfo.buildDate > 0)) {
     746      if (cinfo != NULL && (cinfo->buildDate > 0)) {
    742747       
    743748        (*rprotolist_here).p->get_filteroptions (*collist_here, frequest, fresponse, err, logout);
     
    789794              << " name=cc value=\"" << *collist_here << "\">";
    790795         
    791           if (!cinfo.collectionmeta["collectionname"].empty())
    792         textout << outconvert << disp << cinfo.collectionmeta["collectionname"];
     796          if (!cinfo->collectionmeta["collectionname"].empty())
     797        textout << outconvert << disp << cinfo->collectionmeta["collectionname"];
    793798          else
    794799        textout << outconvert << *collist_here;
     
    816821                 ostream &logout) {
    817822 
     823  if (recpt == NULL) {
     824    logout << "ERROR (queryaction::do_action): This action does not contain information\n"
     825       << "      about any receptionists. The method set_receptionist was probably\n"
     826       << "      not called from the module which instantiated this action.\n";
     827    return true;
     828  }
     829
     830
    818831  if (args["ccs"] == "1") {
    819832    if (!args["cc"].empty()) {
     
    866879  map<text_t, colinfo_t, lttext_t> colinfomap;
    867880
    868   ColInfoResponse_t cinfo;
     881  ColInfoResponse_t *cinfo = NULL;
    869882  comerror_t err;
    870883  FilterRequest_t request;
     
    906919      continue;
    907920    }
    908     collectproto->get_collectinfo (*col_here, cinfo, err, logout);
     921    cinfo = recpt->get_collectinfo_ptr (collectproto, *col_here, logout);
     922    if (cinfo == NULL) {
     923      logout << "ERROR (query_action::search_multiple_collections): get_collectinfo_ptr returned NULL\n";
     924      col_here ++;
     925      continue;
     926    }
    909927   
    910928    browserclass *bptr = browsers->getbrowser (browsertype);
     
    913931    text_t formatstring;
    914932    if (!get_formatstring (classification, browsertype,
    915                cinfo.format, formatstring))
     933               cinfo->format, formatstring))
    916934      formatstring = bptr->get_default_formatstring();
    917935
     
    10691087  text_t classification = "Search";
    10701088
    1071   ColInfoResponse_t cinfo;
    10721089  comerror_t err;
    1073   collectproto->get_collectinfo (collection, cinfo, err, logout);
     1090  ColInfoResponse_t *cinfo = recpt->get_collectinfo_ptr (collectproto, collection, logout);
     1091
     1092  if (cinfo == NULL) {
     1093    logout << "ERROR (query_action::search_single_collection): get_collectinfo_ptr returned NULL\n";
     1094    return false;
     1095  }
    10741096   
    10751097  browserclass *bptr = browsers->getbrowser (browsertype);
     
    10781100  text_t formatstring;
    10791101  if (!get_formatstring (classification, browsertype,
    1080              cinfo.format, formatstring))
     1102             cinfo->format, formatstring))
    10811103    formatstring = bptr->get_default_formatstring();
    10821104
  • trunk/gsdl/src/recpt/queryaction.h

    r928 r1270  
    3232#include "gsdlconf.h"
    3333#include "action.h"
     34#include "receptionist.h"
    3435
    3536struct colinfo_t {
     
    6162
    6263protected:
     64
     65  receptionist *recpt;
     66
    6367  text_t formatstring;
    6468  int num_phrases;
     
    97101  queryaction ();
    98102  virtual ~queryaction () {}
     103
     104  void set_receptionist (receptionist *therecpt) {recpt=therecpt;}
    99105 
    100106  void configure (const text_t &key, const text_tarray &cfgline);
  • trunk/gsdl/src/recpt/receptionist.cpp

    r1268 r1270  
    2828/*
    2929   $Log$
     30   Revision 1.53  2000/07/05 21:49:34  sjboddie
     31   Receptionist now caches collection information to avoid making multiple
     32   get_collectinfo calls to collection server
     33
    3034   Revision 1.52  2000/07/04 02:15:22  sjboddie
    3135   fixed bug causing segmentation fault when an invalid collection
     
    286290}
    287291
    288 
     292void collectioninfo_t::clear () {
     293  gsdl_gsdlhome.clear();
     294  gsdl_gdbmhome.clear();
     295
     296  info_loaded = false;
     297  info.clear();
     298}
    289299
    290300receptionist::receptionist () {
     
    10341044  colinfo_tmap::iterator colend = configinfo.collectinfo.end();
    10351045  while (colhere != colend) {
    1036     gsdlmacrodir = filename_cat ((*colhere).second.gsdl_gsdlhome, "macros");
    1037     maindirs.insert (gsdlmacrodir);
     1046    if (!((*colhere).second.gsdl_gsdlhome).empty()) {
     1047      gsdlmacrodir = filename_cat ((*colhere).second.gsdl_gsdlhome, "macros");
     1048      maindirs.insert (gsdlmacrodir);
     1049    }
    10381050    colhere ++;
    10391051  }
     
    11261138
    11271139    } else {
    1128       ColInfoResponse_t cinfo;
    1129       comerror_t err;
    1130 
    1131       collectproto->get_collectinfo (arg_c, cinfo, err, logout);
    1132 
    1133       if (!cinfo.ccsCols.empty()) {
    1134     args["ccs"] = 1;
    1135     if (args["cc"].empty()) {
    1136       text_tarray::const_iterator col_here = cinfo.ccsCols.begin();
    1137       text_tarray::const_iterator col_end = cinfo.ccsCols.end();
    1138       bool first = true;
    1139       while (col_here != col_end) {
    1140         // make sure it's a valid collection
    1141         if (protocols.getrecptproto (*col_here, logout) != NULL) {
    1142           if (!first) args["cc"].push_back (',');
    1143           args["cc"] += *col_here;
    1144           first = false;
     1140
     1141      ColInfoResponse_t *cinfo = get_collectinfo_ptr (collectproto, arg_c, logout);
     1142
     1143      if (cinfo != NULL) {
     1144    if (!cinfo->ccsCols.empty()) {
     1145      args["ccs"] = 1;
     1146      if (args["cc"].empty()) {
     1147        text_tarray::const_iterator col_here = cinfo->ccsCols.begin();
     1148        text_tarray::const_iterator col_end = cinfo->ccsCols.end();
     1149        bool first = true;
     1150        while (col_here != col_end) {
     1151          // make sure it's a valid collection
     1152          if (protocols.getrecptproto (*col_here, logout) != NULL) {
     1153        if (!first) args["cc"].push_back (',');
     1154        args["cc"] += *col_here;
     1155        first = false;
     1156          }
     1157          col_here ++;
    11451158        }
    1146         col_here ++;
    11471159      }
    11481160    }
     1161      } else {
     1162    logout << "ERROR (receptionist::check_mainargs): get_collectinfo_ptr returned NULL\n";
    11491163      }
    11501164    }
     
    13311345  }
    13321346}
     1347
     1348// gets collection info from cache if found or
     1349// calls collection server (and updates cache)
     1350// returns NULL if there's an error
     1351ColInfoResponse_t *receptionist::get_collectinfo_ptr (recptproto *collectproto,
     1352                              const text_t &collection,
     1353                              ostream &logout) {
     1354 
     1355  // check the cache
     1356  colinfo_tmap::iterator it = configinfo.collectinfo.find (collection);
     1357  if ((it != configinfo.collectinfo.end()) && ((*it).second.info_loaded)) {
     1358    // found it
     1359    return &((*it).second.info);
     1360  }
     1361
     1362  // not cached, get info from collection server
     1363  if (collectproto == NULL) {
     1364    logout << "ERROR: receptionist::get_collectinfo_ptr passed null collectproto\n";
     1365    return NULL;
     1366  }
     1367   
     1368  comerror_t err;
     1369  if (it == configinfo.collectinfo.end()) {
     1370    collectioninfo_t cinfo;
     1371    collectproto->get_collectinfo (collection, cinfo.info, err, logout);
     1372    if (err != noError) {
     1373      outconvertclass text_t2ascii;
     1374      logout << text_t2ascii << "ERROR (receptionist::getcollectinfo_ptr): \""
     1375         << get_comerror_string (err) << "\"while getting collectinfo\n";
     1376      return NULL;
     1377    }
     1378    cinfo.info_loaded = true;
     1379    configinfo.collectinfo[collection] = cinfo;
     1380    return &(configinfo.collectinfo[collection].info);
     1381  } else {
     1382    collectproto->get_collectinfo (collection, (*it).second.info, err, logout);
     1383    if (err != noError) {
     1384      outconvertclass text_t2ascii;
     1385      logout << text_t2ascii << "ERROR (receptionist::getcollectinfo_ptr): \""
     1386         << get_comerror_string (err) << "\"while getting collectinfo\n";
     1387      return NULL;
     1388    }
     1389    (*it).second.info_loaded = true;
     1390    return &((*it).second.info);
     1391  }
     1392}
  • trunk/gsdl/src/recpt/receptionist.h

    r1193 r1270  
    3434#include "cgiargs.h"
    3535#include "display.h"
    36 #include "action.h"
    3736#include "browserclass.h"
    3837#include "recptproto.h"
    3938#include "converter.h"
    4039#include "cfgread.h"
     40#include "action.h"
    4141
    4242// the MACROPRECEDENCE macro is used as a default. override
     
    4949#define MACROPRECEDENCE "c,l"
    5050#endif
     51
     52
     53struct collectioninfo_t {
     54  void clear ();
     55  collectioninfo_t () {clear();}
     56
     57  text_t gsdl_gsdlhome;
     58  text_t gsdl_gdbmhome;
     59
     60  bool info_loaded;
     61  ColInfoResponse_t info;
     62};
     63
     64typedef map<text_t, collectioninfo_t, lttext_t> colinfo_tmap;
    5165
    5266
     
    7286};
    7387
    74 
    7588class receptionist {
    7689protected:
     
    196209  // list. This can be used to save preferences between sessions.
    197210  text_t get_compressed_arg (cgiargsclass &args, ostream &logout);
     211
     212  // gets collection info from cache if found or
     213  // calls collection server (and updates cache)
     214  // returns NULL if there's an error
     215  ColInfoResponse_t *get_collectinfo_ptr (recptproto *collectproto,
     216                      const text_t &collection,
     217                      ostream &logout);
     218
    198219 
    199220protected:
  • trunk/gsdl/src/recpt/statusaction.cpp

    r1266 r1270  
    2828/*
    2929   $Log$
     30   Revision 1.31  2000/07/05 21:49:36  sjboddie
     31   Receptionist now caches collection information to avoid making multiple
     32   get_collectinfo calls to collection server
     33
    3034   Revision 1.30  2000/07/03 22:26:27  nzdl
    3135   fixed a few errors in the macro files (and one in some text printed out
     
    157161                   displayclass &disp, outconvertclass &outconvert,
    158162                   ostream &textout, ostream &logout) {
     163
     164  if (recpt == NULL) return;
    159165
    160166  textout << outconvert << disp
     
    188194            << "</a></td>";
    189195
    190       ColInfoResponse_t cinfo;
    191       (*rprotolist_here).p->get_collectinfo (*collist_here, cinfo, err, logout);
    192       if (err == noError) {
     196      ColInfoResponse_t *cinfo = recpt->get_collectinfo_ptr ((*rprotolist_here).p, *collist_here, logout);
     197      if (cinfo != NULL) {
    193198        text_t collname = *collist_here;
    194         text_tmap::iterator it = cinfo.collectionmeta.find("collectionname");
    195         if (it != cinfo.collectionmeta.end()) collname = (*it).second;
     199        text_tmap::iterator it = cinfo->collectionmeta.find("collectionname");
     200        if (it != cinfo->collectionmeta.end()) collname = (*it).second;
    196201
    197202        textout << "<td>";
    198         if (cinfo.buildDate > 0)
     203        if (cinfo->buildDate > 0)
    199204          textout << outconvert << disp
    200205              << "<a href=\"_httppagex_(about)&c=" << *collist_here
     
    203208        textout << outconvert << disp << collname;
    204209
    205         if (cinfo.buildDate > 0) textout << "</a>";
     210        if (cinfo->buildDate > 0) textout << "</a>";
    206211
    207212        textout << "</td>";
    208213
    209         if (cinfo.isPublic) textout << "<td>yes</td>";
     214        if (cinfo->isPublic) textout << "<td>yes</td>";
    210215        else textout << "<td>no</td>";
    211216       
    212         if (cinfo.buildDate > 0)
     217        if (cinfo->buildDate > 0)
    213218          textout << outconvert << "<td>yes</td>";
    214219        else
     
    651656  } else {
    652657    // rproto can't be NULL to get here
    653     ColInfoResponse_t collectinfo;
    654     comerror_t err;
    655 
    656     rproto->get_collectinfo (arg_c, collectinfo, err, logout);
    657     if (err == noError) {
     658    ColInfoResponse_t *collectinfo = recpt->get_collectinfo_ptr (rproto, arg_c, logout);
     659    if (collectinfo != NULL) {
    658660      textout << outconvert << "<table>\n"
    659661          << "<tr><th>collection name</th><td>\""
    660           << collectinfo.shortInfo.name
     662          << collectinfo->shortInfo.name
    661663          << "\"</td></tr>\n"
    662664
    663665          << "<tr><th>host</th><td>\""
    664           << collectinfo.shortInfo.host
     666          << collectinfo->shortInfo.host
    665667          << "\"</td></tr>\n"
    666668
    667669          << "<tr><th>port</th><td>\""
    668           << collectinfo.shortInfo.port
     670          << collectinfo->shortInfo.port
    669671          << "\"</td></tr>\n"
    670672
    671673          << "<tr><th>is public?</th><td>";
    672       if (collectinfo.isPublic) textout << outconvert << "true";
     674      if (collectinfo->isPublic) textout << outconvert << "true";
    673675      else textout << outconvert << "false";
    674676      textout << outconvert
     
    676678
    677679          << "<tr><th>is beta?</th><td>";
    678       if (collectinfo.isBeta) textout << outconvert << "true";
     680      if (collectinfo->isBeta) textout << outconvert << "true";
    679681      else textout << outconvert << "false";
    680682      textout << outconvert
     
    682684
    683685          << "<tr><th>build date</th><td>\""
    684           << collectinfo.buildDate
     686          << collectinfo->buildDate
    685687          << "\"</td></tr>\n"
    686688
    687689          << "<tr><th>interface languages</th><td>";
    688       text_tarray::iterator languages_here = collectinfo.languages.begin();
    689       text_tarray::iterator languages_end = collectinfo.languages.end();
     690      text_tarray::iterator languages_here = collectinfo->languages.begin();
     691      text_tarray::iterator languages_end = collectinfo->languages.end();
    690692      bool languages_first = true;
    691693      while (languages_here != languages_end) {
     
    697699
    698700      textout << "<tr><th valign=top>collection metadata</th><td><table>\n";
    699       text_tmap::iterator meta_here = collectinfo.collectionmeta.begin();
    700       text_tmap::iterator meta_end = collectinfo.collectionmeta.end();
     701      text_tmap::iterator meta_here = collectinfo->collectionmeta.begin();
     702      text_tmap::iterator meta_end = collectinfo->collectionmeta.end();
    701703      while (meta_here != meta_end) {
    702704    textout << outconvert << "<tr><td>" << (*meta_here).first
     
    707709
    708710      textout << "<tr><th valign=top>format info</th><td><table>\n";
    709       text_tmap::iterator format_here = collectinfo.format.begin();
    710       text_tmap::iterator format_end = collectinfo.format.end();
     711      text_tmap::iterator format_here = collectinfo->format.begin();
     712      text_tmap::iterator format_end = collectinfo->format.end();
    711713      while (format_here != format_end) {
    712714    textout << outconvert << "<tr><td>" << (*format_here).first
     
    717719
    718720      textout << "<tr><th valign=top>building info</th><td><table>\n";
    719       text_tmap::iterator building_here = collectinfo.building.begin();
    720       text_tmap::iterator building_end = collectinfo.building.end();
     721      text_tmap::iterator building_here = collectinfo->building.begin();
     722      text_tmap::iterator building_end = collectinfo->building.end();
    721723      while (building_here != building_end) {
    722724    textout << outconvert << "<tr><td>" << (*building_here).first
     
    730732
    731733          << "<tr><th>number of documents</th><td>\""
    732           << collectinfo.numDocs
     734          << collectinfo->numDocs
    733735          << "\"</td></tr>\n"
    734736
    735737          << "<tr><th>number of sections</th><td>\""
    736           << collectinfo.numSections
     738          << collectinfo->numSections
    737739          << "\"</td></tr>\n"
    738740
    739741          << "<tr><th>number of words</th><td>\""
    740           << collectinfo.numWords
     742          << collectinfo->numWords
    741743          << "\"</td></tr>\n"
    742744
    743745          << "<tr><th>number of bytes</th><td>\""
    744           << collectinfo.numBytes
     746          << collectinfo->numBytes
    745747          << "\"</td></tr>\n"
    746748
    747749          << "<tr><th>preferred receptionist</th><td>\""
    748           << collectinfo.receptionist
     750          << collectinfo->receptionist
    749751          << "\"</td></tr>\n"
    750752
     
    752754     
    753755    } else {
    754       textout << outconvert << "Error (" << get_comerror_string (err)
    755           << ") while getting collect information\n";
     756      textout << "ERROR (statusaction::output_collectioninfo): while getting collect information\n";
    756757    }
    757758
     
    760761    InfoFilterOptionsRequest_t filteroptions_request;
    761762    InfoFilterOptionsResponse_t filteroptions;
     763    comerror_t err;
    762764    rproto->get_filterinfo (arg_c, filterinfo, err, logout);
    763765    if (err == noError) {
  • trunk/gsdl/src/w32server/settings.h

    r902 r1270  
    1212#include "text_t.h"
    1313#include "cfgread.h"
     14#include "receptionist.h"
    1415
    1516// library settings
Note: See TracChangeset for help on using the changeset viewer.