Changeset 22142 for main/trunk


Ignore:
Timestamp:
2010-05-20T20:59:01+12:00 (14 years ago)
Author:
davidb
Message:

For the CGI 'e' variable to be inter-changable between mod_gsdl and library.cgi then they need to have exactly the same actions. The code has been refactored so they now use a shared function to do this, the ensure this is the case.

Location:
main/trunk/greenstone2/runtime-src/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/runtime-src/src/protocol/recptproto.h

    r16310 r22142  
    5353class recptproto {
    5454public:
     55
     56  recptproto() {};
     57  virtual ~recptproto() {};
    5558
    5659  // add collection server to protocol
  • main/trunk/greenstone2/runtime-src/src/protocol/recptprototools.cpp

    r16180 r22142  
    143143  metadata.insert ("haschildren");
    144144
    145   if (get_info (OID, collection, lang, metadata, false, collectproto,   response, logout))
     145  if (get_info (OID, collection, lang, metadata, true, collectproto,    response, logout))
    146146  {
    147147    if (response.docInfo[0].metadata["haschildren"].values[0] == "1")
     
    216216  {
    217217    FilterResponse_t tmp;
    218     bool getParents = false;
     218    bool getParents = true;
    219219    get_children (section.OID, collection, lang, metadata, getParents, collectproto, tmp, logout);
    220220    ResultDocInfo_tarray::iterator thisdoc = tmp.docInfo.begin();
     
    244244
    245245  // get topOIDs info
    246   if (get_info (topOID, collection, lang, metadata, false, collectproto, response, logout))
     246  if (get_info (topOID, collection, lang, metadata, true, collectproto, response, logout))
    247247  {
    248248    recurse_contents (response.docInfo[0], is_classify, collection, lang, metadata, collectproto, response, logout);
  • main/trunk/greenstone2/runtime-src/src/recpt/cgiwrapper.cpp

    r19109 r22142  
    5454#endif
    5555
     56#include "authenaction.h"
     57#include "browseaction.h"
     58#include "collectoraction.h"
     59#include "depositoraction.h"
     60#include "documentaction.h"
     61#include "dynamicclassifieraction.h"
     62#include "extlinkaction.h"
     63#include "pageaction.h"
     64#ifdef ENABLE_MGPP
     65#include "phindaction.h"
     66#endif
     67#include "pingaction.h"
     68#include "queryaction.h"
     69
     70#if defined(USE_SQLITE)
     71#include "sqlqueryaction.h"
     72#endif
     73
     74#include "tipaction.h"
     75#include "statusaction.h"
     76#include "usersaction.h"
     77#include "configaction.h"
     78
     79#include "vlistbrowserclass.h"
     80#include "hlistbrowserclass.h"
     81#include "datelistbrowserclass.h"
     82#include "invbrowserclass.h"
     83#include "pagedbrowserclass.h"
     84#include "htmlbrowserclass.h"
     85#include "phindbrowserclass.h"
     86
    5687
    5788#ifdef USE_FASTCGI
     
    450481}
    451482
     483
     484
     485
     486void add_all_actions(receptionist& recpt, userdbclass* udb, keydbclass* kdb)
     487{
     488  // the list of actions.
     489
     490#ifdef GSDL_USE_TIP_ACTION
     491  tipaction* atipaction = new tipaction();
     492  recpt.add_action (atipaction);
     493#endif
     494
     495#ifdef GSDL_USE_STATUS_ACTION
     496  statusaction *astatusaction = new statusaction();
     497  astatusaction->set_receptionist (&recpt);
     498  recpt.add_action (astatusaction);
     499#endif
     500
     501  pageaction *apageaction = new pageaction();
     502  apageaction->set_receptionist (&recpt);
     503  recpt.add_action (apageaction);
     504
     505#ifdef GSDL_USE_PING_ACTION
     506  recpt.add_action (new pingaction());
     507#endif
     508
     509  queryaction *aqueryaction = new queryaction();
     510  aqueryaction->set_receptionist (&recpt);
     511  recpt.add_action (aqueryaction);
     512
     513#if defined(USE_SQLITE)
     514  sqlqueryaction *asqlqueryaction = new sqlqueryaction();
     515  asqlqueryaction->set_receptionist (&recpt);
     516  recpt.add_action (asqlqueryaction);
     517#endif
     518
     519  documentaction *adocumentaction = new documentaction();
     520  adocumentaction->set_receptionist (&recpt);
     521  recpt.add_action (adocumentaction);
     522
     523#ifdef GSDL_USE_USERS_ACTION
     524  usersaction *ausersaction = new usersaction();
     525  ausersaction->set_userdb(udb);
     526  recpt.add_action (ausersaction);
     527#endif
     528
     529#ifdef GSDL_USE_EXTLINK_ACTION
     530  extlinkaction *aextlinkaction = new extlinkaction();
     531  aextlinkaction->set_receptionist(&recpt);
     532  recpt.add_action (aextlinkaction);
     533#endif
     534       
     535#ifdef GSDL_USE_AUTHEN_ACTION
     536  authenaction *aauthenaction = new authenaction();
     537  aauthenaction->set_userdb(udb);
     538  aauthenaction->set_keydb(kdb);
     539  aauthenaction->set_receptionist(&recpt);
     540  recpt.add_action (aauthenaction);
     541#endif
     542
     543#ifdef GSDL_USE_COLLECTOR_ACTION
     544  collectoraction *acollectoraction = new collectoraction();
     545  acollectoraction->set_receptionist (&recpt);
     546  recpt.add_action(acollectoraction);
     547#endif
     548
     549#ifdef GSDL_USE_DEPOSITOR_ACTION
     550  depositoraction *adepositoraction = new depositoraction();
     551  adepositoraction->set_receptionist (&recpt);
     552  recpt.add_action(adepositoraction);
     553#endif
     554
     555#ifdef GSDL_USE_BROWSE_ACTION
     556  browseaction *abrowseaction = new browseaction();
     557  abrowseaction->set_receptionist (&recpt);
     558  recpt.add_action(abrowseaction);
     559#endif
     560
     561#ifdef GSDL_USE_PHIND_ACTION
     562  // Phind uses MPPP,do we also need to check if ENABLE_MGPP is set??
     563  phindaction *aphindaction = new phindaction();
     564  recpt.add_action(aphindaction);
     565#endif
     566
     567#ifdef GSDL_USE_GTI_ACTION
     568  gtiaction *agtiaction = new gtiaction();
     569  agtiaction->set_receptionist(&recpt);
     570  recpt.add_action(agtiaction);
     571#endif
     572
     573  dynamicclassifieraction *adynamicclassifieraction = new dynamicclassifieraction();
     574  adynamicclassifieraction->set_receptionist(&recpt);
     575  recpt.add_action(adynamicclassifieraction); 
     576
     577#if defined(USE_MYSQL) || defined(USE_ACCESS)
     578  orderaction *aorderaction = new orderaction();
     579  aorderaction->set_receptionist(&recpt);
     580  recpt.add_action(aorderaction);
     581#endif
     582
     583  // action that allows collections to be added, released etc.  when server
     584  // is persistent (e.g. fastcgi or when Greenstone is configured as an
     585  // Apache module).  Presumably this includes Windows server.exe as well
     586
     587  // Want to always include it in list of actions even if compiling
     588  // Greenstone to be used in a non-persistent way (e.g. library.cgi).
     589  // This is so the e-variable that is formed is consistent between the
     590  // persisent executable and the non-persistent executable
     591  //
     592
     593  configaction *aconfigaction = new configaction();
     594  aconfigaction->set_receptionist(&recpt);
     595  recpt.add_action(aconfigaction);
     596}
     597
     598
     599
     600void add_all_browsers(receptionist& recpt)
     601{
     602  // list of browsers
     603  vlistbrowserclass *avlistbrowserclass = new vlistbrowserclass();
     604  avlistbrowserclass->set_receptionist(&recpt);
     605  recpt.add_browser (avlistbrowserclass);
     606  recpt.setdefaultbrowser ("VList");
     607
     608  hlistbrowserclass *ahlistbrowserclass = new hlistbrowserclass();
     609  ahlistbrowserclass->set_receptionist(&recpt);
     610  recpt.add_browser (ahlistbrowserclass);
     611
     612#ifdef GSDL_USE_DATELIST_BROWSER
     613  datelistbrowserclass *adatelistbrowserclass = new datelistbrowserclass();
     614  recpt.add_browser (adatelistbrowserclass);
     615#endif
     616
     617  invbrowserclass *ainvbrowserclass = new invbrowserclass();
     618  recpt.add_browser (ainvbrowserclass);
     619
     620#ifdef GSDL_USE_PAGED_BROWSER
     621  pagedbrowserclass *apagedbrowserclass = new pagedbrowserclass();
     622  recpt.add_browser (apagedbrowserclass);
     623#endif
     624
     625#ifdef GSDL_USE_HTML_BROWSER
     626  htmlbrowserclass *ahtmlbrowserclass = new htmlbrowserclass();
     627  recpt.add_browser (ahtmlbrowserclass);
     628#endif
     629
     630#ifdef GSDL_USE_PHIND_BROWSER
     631  phindbrowserclass *aphindbrowserclass = new phindbrowserclass();;
     632  recpt.add_browser (aphindbrowserclass);
     633#endif
     634}
     635
     636
    452637// cgiwrapper does everything necessary to output a page
    453638// using the cgi protocol. If this is being run for a particular
  • main/trunk/greenstone2/runtime-src/src/recpt/cgiwrapper.h

    r15453 r22142  
    3030
    3131#include "receptionist.h"
     32#include "userdb.h"
     33
     34void add_all_actions(receptionist& recpt, userdbclass* udb, keydbclass* kdb);
     35void add_all_browsers(receptionist& recpt);
    3236
    3337// cgiwrapper does everything necessary to output a page
  • main/trunk/greenstone2/runtime-src/src/recpt/librarymain.cpp

    r22067 r22142  
    3636
    3737#include "action.h"
    38 #include "authenaction.h"
    39 #include "browseaction.h"
    40 #include "collectoraction.h"
    41 #include "depositoraction.h"
    42 #include "documentaction.h"
    43 #include "dynamicclassifieraction.h"
    44 #include "extlinkaction.h"
    45 #include "pageaction.h"
    46 #ifdef ENABLE_MGPP
    47 #include "phindaction.h"
    48 #endif
    49 #include "pingaction.h"
    50 #include "queryaction.h"
    51 
    52 #if defined(USE_SQLITE)
    53 #include "sqlqueryaction.h"
    54 #endif
    55 
    56 #include "tipaction.h"
    57 #include "statusaction.h"
    58 #include "usersaction.h"
    59 
    6038#include "browserclass.h"
    61 #include "vlistbrowserclass.h"
    62 #include "hlistbrowserclass.h"
    63 #include "datelistbrowserclass.h"
    64 #include "invbrowserclass.h"
    65 #include "pagedbrowserclass.h"
    66 #include "htmlbrowserclass.h"
    67 #include "phindbrowserclass.h"
    6839
    6940
     
    12293#endif
    12394
    124   // the list of actions. Note: these actions will become invalid
    125   // at the end of this function. We will clean them.
    126 
    127 #ifdef GSDL_USE_TIP_ACTION
    128   recpt.add_action (new tipaction());
    129 #endif
    130 
    131 #ifdef GSDL_USE_STATUS_ACTION
    132   statusaction *astatusaction = new statusaction();
    133   astatusaction->set_receptionist (&recpt);
    134   recpt.add_action (astatusaction);
    135 #endif
    136 
    137   pageaction *apageaction = new pageaction();
    138   apageaction->set_receptionist (&recpt);
    139   recpt.add_action (apageaction);
    140 
    141 #ifdef GSDL_USE_PING_ACTION
    142   recpt.add_action (new pingaction());
    143 #endif
    144 
    145   queryaction *aqueryaction = new queryaction();
    146   aqueryaction->set_receptionist (&recpt);
    147   recpt.add_action (aqueryaction);
    148 
    149 #if defined(USE_SQLITE)
    150   sqlqueryaction *asqlqueryaction = new sqlqueryaction();
    151   asqlqueryaction->set_receptionist (&recpt);
    152   recpt.add_action (asqlqueryaction);
    153 #endif
    154 
    155   documentaction *adocumentaction = new documentaction();
    156   adocumentaction->set_receptionist (&recpt);
    157   recpt.add_action (adocumentaction);
    158 
    15995  userdbclass *udb = new userdbclass(gsdlhome);
    16096  keydbclass *kdb = new keydbclass(gsdlhome);
    16197
    162 #ifdef GSDL_USE_USERS_ACTION
    163   usersaction *ausersaction = new usersaction();
    164   ausersaction->set_userdb(udb);
    165   recpt.add_action (ausersaction);
    166 #endif
     98  add_all_actions(recpt,udb,kdb);
     99  // Note: these actions will become invalid at the end of this function.
     100  // => We will retrieve them from the receptionist and delete them
    167101
    168 #ifdef GSDL_USE_EXTLINK_ACTION
    169   extlinkaction *aextlinkaction = new extlinkaction();
    170   aextlinkaction->set_receptionist(&recpt);
    171   recpt.add_action (aextlinkaction);
    172 #endif
    173        
    174 #ifdef GSDL_USE_AUTHEN_ACTION
    175   authenaction *aauthenaction = new authenaction();
    176   aauthenaction->set_userdb(udb);
    177   aauthenaction->set_keydb(kdb);
    178   aauthenaction->set_receptionist(&recpt);
    179   recpt.add_action (aauthenaction);
    180 #endif
    181 
    182 #ifdef GSDL_USE_COLLECTOR_ACTION
    183   collectoraction *acollectoraction = new collectoraction();
    184   acollectoraction->set_receptionist (&recpt);
    185   recpt.add_action(acollectoraction);
    186 #endif
    187 
    188 #ifdef GSDL_USE_DEPOSITOR_ACTION
    189   depositoraction *adepositoraction = new depositoraction();
    190   adepositoraction->set_receptionist (&recpt);
    191   recpt.add_action(adepositoraction);
    192 #endif
    193 
    194 #ifdef GSDL_USE_BROWSE_ACTION
    195   browseaction *abrowseaction = new browseaction();
    196   abrowseaction->set_receptionist (&recpt);
    197   recpt.add_action(abrowseaction);
    198 #endif
    199 
    200 #ifdef GSDL_USE_PHIND_ACTION
    201   recpt.add_action(new phindaction());
    202 #endif
    203 
    204 #ifdef GSDL_USE_GTI_ACTION
    205   gtiaction *agtiaction = new gtiaction();
    206   agtiaction->set_receptionist(&recpt);
    207   recpt.add_action(agtiaction);
    208 #endif
    209 
    210   dynamicclassifieraction *adynamicclassifieraction = new dynamicclassifieraction();
    211   adynamicclassifieraction->set_receptionist(&recpt);
    212   recpt.add_action(adynamicclassifieraction); 
    213 
    214   // list of browsers
    215   vlistbrowserclass avlistbrowserclass;
    216   avlistbrowserclass.set_receptionist(&recpt);
    217   recpt.add_browser (&avlistbrowserclass);
    218   recpt.setdefaultbrowser ("VList");
    219 
    220   hlistbrowserclass ahlistbrowserclass;
    221   ahlistbrowserclass.set_receptionist(&recpt);
    222   recpt.add_browser (&ahlistbrowserclass);
    223 
    224 #ifdef GSDL_USE_DATELIST_BROWSER
    225   datelistbrowserclass adatelistbrowserclass;
    226   recpt.add_browser (&adatelistbrowserclass);
    227 #endif
    228 
    229   invbrowserclass ainvbrowserclass;
    230   recpt.add_browser (&ainvbrowserclass);
    231 
    232 #ifdef GSDL_USE_PAGED_BROWSER
    233   pagedbrowserclass apagedbrowserclass;
    234   recpt.add_browser (&apagedbrowserclass);
    235 #endif
    236 
    237 #ifdef GSDL_USE_HTML_BROWSER
    238   htmlbrowserclass ahtmlbrowserclass;
    239   recpt.add_browser (&ahtmlbrowserclass);
    240 #endif
    241 
    242 #ifdef GSDL_USE_PHIND_BROWSER
    243   phindbrowserclass aphindbrowserclass;
    244   recpt.add_browser (&aphindbrowserclass);
    245 #endif
     102  add_all_browsers(recpt);
     103  // Browsers are not currently deleted (at all?) in code.  Seems likely they
     104  // should be treated in a similar fashion to actions
    246105
    247106  cgiwrapper (recpt, "");
     
    252111  // clean up the actions
    253112  actionmapclass::iterator thisAction = recpt.get_actionmap_ptr()->begin();
    254   actionmapclass::iterator endAction = recpt.get_actionmap_ptr()->begin();
     113  actionmapclass::iterator endAction = recpt.get_actionmap_ptr()->end();
    255114  while (thisAction != endAction) {
    256     delete thisAction->second.a; thisAction->second.a = NULL;
     115    delete thisAction->second.a;
     116    thisAction->second.a = NULL;
    257117    ++thisAction;
    258118  }
     
    260120  recpt.get_actionmap_ptr()->erase(thisAction, endAction);
    261121
     122
     123  /*
     124  // clean up the browsers
     125  browsermapclass::iterator thisBrowser = recpt.get_browsermap_ptr()->begin();
     126  browsermapclass::iterator endBrowser = recpt.get_browsermap_ptr()->end();
     127  while (thisBrowser != endBrowser) {
     128    delete thisBrowser->second.a;
     129    thisBrowser->second.a = NULL;
     130    ++thisBrowser;
     131  }
     132  thisBrowser = recpt.get_browsermap_ptr()->begin();
     133  recpt.get_browsermap_ptr()->erase(thisBrowser, endBrowser);
     134  */
     135
    262136  return 0;
    263137}
  • main/trunk/greenstone2/runtime-src/src/recpt/mod_gsdl.cpp

    r22048 r22142  
    8181
    8282#include "action.h"
    83 #include "pageaction.h"
    84 #include "queryaction.h"
    85 
    86 #if defined(USE_SQLITE)
    87 #include "sqlqueryaction.h"
    88 #endif
    89 
    90 #include "documentaction.h"
    91 #include "extlinkaction.h"
    92 #ifdef ENABLE_MGPP
    93 #include "phindaction.h"
    94 #endif
    95 #if defined(USE_MYSQL) || defined(USE_ACCESS)
    96 #include "orderaction.h"
    97 #endif
    98 #include "configaction.h"
    99 
    10083#include "browserclass.h"
    101 #include "vlistbrowserclass.h"
    102 #include "hlistbrowserclass.h"
    103 #include "datelistbrowserclass.h"
    104 #include "invbrowserclass.h"
    105 #include "pagedbrowserclass.h"
    106 #include "phindbrowserclass.h"
    107 
    108 #include <strstream>
     84
     85#define GSDL_USE_OSTRINGSTREAM 1
     86// ostrstream is deprecated => switch to using ostringstream
     87// Doing this with the above define so it is easy to switch
     88// back to ostrstream this backwards compatability is needed
     89// for some reason.
     90
     91#if defined(GSDL_USE_OSTRINGSTREAM)
     92#  include <sstream>
     93#else
     94#  if defined(GSDL_USE_IOS_H)
     95#    if defined(__WIN32__)
     96#      include <strstrea.h> // vc4
     97#    else
     98#      include <strstream.h>
     99#    endif
     100#  else
     101#    include <strstream>
     102#  endif
     103#endif
    109104
    110105receptionist recpt;
     
    252247  // class as a filler (but most likely won't work) - only useful
    253248  // if creating a binary that doesn't require access to the database
    254   dbclass *db = new gdbmclass();
     249  dbclass *db = new gdbmclass(gsdlhome);
    255250
    256251#endif
     
    260255#endif
    261256
    262   // the list of actions.
    263   pageaction *apageaction = new pageaction();
    264   apageaction->set_receptionist(&recpt);
    265   recpt.add_action(apageaction);
     257  userdbclass *udb = new userdbclass(gsdlhome);
     258  keydbclass *kdb = new keydbclass(gsdlhome);
     259  // do these two database classes ever get deleted in the module version
     260  // of Greenstone?
     261
     262  // librarymain.cpp deletes these when its finished its function
     263  // does comparable code need to be put into "gsdl_deinit()" routine
     264  // whatever that might be called in reality?
     265
     266  add_all_actions(recpt,udb,kdb);
     267  add_all_browsers(recpt);
    266268 
    267   queryaction *aqueryaction = new queryaction();
    268   aqueryaction->set_receptionist(&recpt);
    269   recpt.add_action(aqueryaction);
    270  
    271 #if defined(USE_SQLITE)
    272   sqlqueryaction *asqlqueryaction = new sqlqueryaction();
    273   asqlqueryaction->set_receptionist (&recpt);
    274   recpt.add_action (asqlqueryaction);
    275 #endif
    276 
    277   documentaction *adocumentaction = new documentaction();
    278   adocumentaction->set_receptionist(&recpt);
    279   recpt.add_action(adocumentaction);
    280 
    281   extlinkaction *anextlinkaction = new extlinkaction();
    282   recpt.add_action(anextlinkaction);
    283 
    284   // phindaction is for MGPP and uses MGQuery
    285 #ifdef ENABLE_MGPP
    286   phindaction *aphindaction = new phindaction();
    287   recpt.add_action(aphindaction);
    288 #endif
    289 
    290 #if defined(USE_MYSQL) || defined(USE_ACCESS)
    291   orderaction *aorderaction = new orderaction();
    292   aorderaction->set_receptionist(&recpt);
    293   recpt.add_action(aorderaction);
    294 #endif
    295 
    296   configaction *aconfigaction = new configaction();
    297   aconfigaction->set_receptionist(&recpt);
    298   recpt.add_action(aconfigaction);
    299 
    300   // list of browsers
    301   vlistbrowserclass *avlistbrowserclass = new vlistbrowserclass();
    302   recpt.add_browser(avlistbrowserclass);
    303   recpt.setdefaultbrowser("VList");
    304 
    305   hlistbrowserclass *ahlistbrowserclass = new hlistbrowserclass();
    306   recpt.add_browser(ahlistbrowserclass);
    307 
    308   datelistbrowserclass *adatelistbrowserclass = new datelistbrowserclass();
    309   recpt.add_browser(adatelistbrowserclass);
    310 
    311   invbrowserclass *ainvbrowserclass = new invbrowserclass();
    312   recpt.add_browser(ainvbrowserclass);
    313 
    314   pagedbrowserclass *apagedbrowserclass = new pagedbrowserclass();
    315   recpt.add_browser(apagedbrowserclass);
    316 
    317   phindbrowserclass *aphindbrowserclass = new phindbrowserclass();;
    318   recpt.add_browser(aphindbrowserclass);
    319  
     269
    320270  // configure everything
    321271  recpt.configure("gsdlhome", gsdlhome);
     
    500450  }
    501451
     452#ifdef GSDL_USE_OSTRINGSTREAM
     453  ostringstream pageout;
     454#else
    502455  ostrstream pageout;
     456#endif
    503457
    504458  // get http headers
     
    552506      return 500;
    553507    }
     508#ifdef GSDL_USE_OSTRINGSTREAM
     509    string out = pageout.str();
     510    ap_rwrite(out.c_str(), out.size(), r);
     511#else
    554512    char *out = pageout.str();
    555513    ap_rwrite(out, pageout.pcount(), r);
    556514    pageout.rdbuf()->freeze(0);
     515#endif
    557516  }
    558517
Note: See TracChangeset for help on using the changeset viewer.