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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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 ++;
Note: See TracChangeset for help on using the changeset viewer.