Changeset 1649 for trunk/gsdl


Ignore:
Timestamp:
2000-11-03T10:21:01+13:00 (24 years ago)
Author:
sjboddie
Message:

Tidied up collectoraction some more and created an add_collection
function in nullproto that does all the work of setting up a
local collection server

Location:
trunk/gsdl/src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/src/recpt/collectoraction.cpp

    r1507 r1649  
    3535#include "cfgread.h"
    3636#include "gsdltools.h"
     37#include "nullproto.h"
    3738
    3839#if !defined (__WIN32__)
     
    359360    char c = fbld_in.get();
    360361    fbld_in.close();
    361     if (c == '0') current_page = "bilddone";
     362    if (c == '0') {
     363      // success - we need to create and configure a collection server for the
     364      // newly built collection (for fastcgi and local library where
     365      // initialization isn't going to be redone when the user clicks the
     366      // "view your new collection" button
     367      create_colserver (args["bc1dirname"], logout);
     368      current_page = "bilddone";
     369    }
    362370    else if (c == '4' || c == '5') message = "installfail";
    363371    else current_page = "bildfail";
     
    772780  }
    773781
    774   disp.setmacro ("statusline", "collector", statusline);
     782  disp.setmacro ("statusline", "collector", dm_safe(statusline));
    775783
    776784}
     
    11631171  options += " -collectdir \"" + tmpdir + "\" ";
    11641172  text_t optionfile = filename_cat (tmpdir, "mkcol.opt");
    1165   char *optionfilet = optionfile.getcstr();
    1166   ofstream ofile_out (optionfilet);
    1167   delete optionfilet;
     1173  char *optionfilec = optionfile.getcstr();
     1174  ofstream ofile_out (optionfilec);
     1175  delete optionfilec;
    11681176  if (!ofile_out) {
    11691177    message = "tmpfail";
     
    13361344  return false;
    13371345}
     1346
     1347// create and initialize a new collection server and
     1348// add it to the null protocol.
     1349void collectoraction::create_colserver (const text_t &collection, ostream &logout) {
     1350
     1351  recptprotolistclass *protos = recpt->get_recptprotolist_ptr();
     1352  recptprotolistclass::iterator rprotolist_here = protos->begin();
     1353  recptprotolistclass::iterator rprotolist_end = protos->end();
     1354  while (rprotolist_here != rprotolist_end) {
     1355    if ((*rprotolist_here).p != NULL) {
     1356      if ((*rprotolist_here).p->get_protocol_name () == "nullproto") {
     1357    // create collection server and add it to nullproto
     1358    (*rprotolist_here).p->add_collection (collection, recpt, gsdlhome, gsdlhome);
     1359    // make sure gsdlhome is configured
     1360    text_tarray tmp;
     1361    tmp.push_back (gsdlhome);
     1362    (*rprotolist_here).p->configure ("gsdlhome", tmp);
     1363    // re-initialize the null protocol
     1364    if (!(*rprotolist_here).p->init (logout)) {
     1365      logout << "collectoraction::create_colserver: nullproto init failed\n";
     1366    }
     1367    return;
     1368      }
     1369    }
     1370    rprotolist_here ++;
     1371  }
     1372
     1373  logout << "collectoraction::create_colserver: no valid nullproto found\n";
     1374}
  • trunk/gsdl/src/recpt/collectoraction.h

    r1485 r1649  
    7575  text_t get_collectdir (cgiargsclass &args);
    7676
    77   bool collectoraction::uses_weird_plugin (const text_t &collection);
     77  bool uses_weird_plugin (const text_t &collection);
     78
     79  void create_colserver (const text_t &collection, ostream &logout);
    7880
    7981public:
  • trunk/gsdl/src/recpt/librarymain.cpp

    r1643 r1649  
    2626#include "receptionist.h"
    2727#include "cgiwrapper.h"
     28#include "fileutil.h"
    2829#include "nullproto.h"
    2930// z39.50 stuff - johnmcp
    3031#include "z3950proto.h"
    31 #include "collectserver.h"
    32 #include "filter.h"
    33 #include "browsefilter.h"
    34 #include "mgqueryfilter.h"
    35 #include "mgppqueryfilter.h"
    36 #include "infodbclass.h"
    37 #include "mggdbmsource.h"
    38 #include "mgsearch.h"
    39 #include "mgppsearch.h"
    40 #include "fileutil.h"
    41 #include <assert.h>
    4232
    4333#include "action.h"
     
    8676   
    8777    // ignore the modelcol
    88 
    8978    if (*thiscol == "modelcol") {
    9079      thiscol ++;
     
    9281    }
    9382   
    94     // read config file to see if built with mg or mgpp
    95     // (for now we'll just ignore mgpp if on windows)
    96     text_t buildtype = "mg"; // mg is default
    97 #ifndef __WIN32__
    98     text_tarray cfgline;
    99     text_t key;
    100     text_t filename = filename_cat(collectdir, *thiscol, "index/build.cfg");
    101     ifstream confin(filename.getcstr());
    102 
    103     if (confin) {
    104       while (read_cfg_line(confin, cfgline) >= 0) {
    105     if (cfgline.size() ==2 ) {
    106       key = cfgline[0];
    107       cfgline.erase(cfgline.begin());
    108       if (key =="buildtype") {
    109         buildtype = cfgline[0];
    110         break;
    111       }
    112     }
    113       }
    114     }
     83    // create collection server and add to null protocol
     84    nproto.add_collection (*thiscol, &recpt, gsdlhome, gsdlhome);
    11585   
    116     confin.close();
    117 #endif
    118 
    119     collectserver *cserver = new collectserver();
    120     gdbmclass *gdbmhandler = new gdbmclass();
    121 
    122     // add a null filter
    123     filterclass *filter = new filterclass ();
    124     cserver->add_filter (filter);
    125      
    126     // add a browse filter
    127     browsefilterclass *browsefilter = new browsefilterclass();
    128     browsefilter->set_gdbmptr (gdbmhandler);
    129 
    130     cserver->add_filter (browsefilter); 
    131  
    132     if (buildtype == "mg") {
    133        mgsearchclass *mgsearch = new mgsearchclass();
    134  
    135        // add a query filter
    136        mgqueryfilterclass *queryfilter = new mgqueryfilterclass();
    137        queryfilter->set_gdbmptr (gdbmhandler);
    138        queryfilter->set_mgsearchptr (mgsearch);
    139        cserver->add_filter (queryfilter);
    140        
    141        // add a mg and gdbm source
    142        mggdbmsourceclass *mggdbmsource = new mggdbmsourceclass ();
    143        mggdbmsource->set_gdbmptr (gdbmhandler);
    144        mggdbmsource->set_mgsearchptr (mgsearch);
    145        cserver->add_source (mggdbmsource);
    146     }
    147 #ifndef __WIN32__
    148 
    149     else if (buildtype == "mgpp") {
    150      
    151       mgppsearchclass *mgsearch = new mgppsearchclass();
    152 
    153       // add a query filter
    154       mgppqueryfilterclass *queryfilter = new mgppqueryfilterclass();
    155       queryfilter->set_gdbmptr (gdbmhandler);
    156       queryfilter->set_mgsearchptr (mgsearch);
    157       cserver->add_filter (queryfilter);
    158      
    159       // add a mg and gdbm source
    160       mggdbmsourceclass *mggdbmsource = new mggdbmsourceclass ();
    161       mggdbmsource->set_gdbmptr (gdbmhandler);
    162       mggdbmsource->set_mgsearchptr (mgsearch);
    163       cserver->add_source (mggdbmsource);
    164    
    165     }
    166 #endif   
    167 
    168     // inform collection server and everything it contains about its
    169     // collection name
    170     cserver->configure ("collection", *thiscol);
    171  
    172     // configure receptionist's collectinfo structure
    173     text_tarray colinfo;
    174     colinfo.push_back (*thiscol);
    175     colinfo.push_back (gsdlhome);
    176     colinfo.push_back (gsdlhome);
    177     recpt.configure ("collectinfo", colinfo);
    178    
    179     nproto.add_collectserver (cserver);
    18086    thiscol ++;
    18187  }
    182  
     88
    18389  // add the protocol to the receptionist
    18490  recpt.add_protocol (&nproto);
    185  
    186 
    18791
    18892  // z39.50 stuff - johnmcp
     
    226130  aroutconvert.setmapfile (armapfile);
    227131  recpt.add_converter ("a", &arinconvert, &aroutconvert); 
    228 
     132 
    229133  // hindi
    230134//    armapfile = filename_cat (gsdlhome, "unicode", "MAPPINGS");
     
    304208  return 0;
    305209}
     210
  • trunk/gsdl/src/recpt/nullproto.cpp

    r1459 r1649  
    2828#include <assert.h>
    2929
     30#include "filter.h"
     31#include "browsefilter.h"
     32#include "mgqueryfilter.h"
     33#include "mgppqueryfilter.h"
     34#include "infodbclass.h"
     35#include "mggdbmsource.h"
     36#include "mgsearch.h"
     37#include "mgppsearch.h"
     38#include "fileutil.h"
     39
     40
    3041nullproto::~nullproto() {
    3142  collectservermapclass::iterator here = cservers.begin();
     
    3950  }
    4051  cservers.clear();
     52}
     53
     54// add_collection sets up the collectionserver and calls
     55// add_collectserver
     56void nullproto::add_collection (const text_t &collection, void *recpt,
     57                const text_t &gsdlhome, const text_t &gdbmhome) {
     58     
     59  // read config file to see if built with mg or mgpp
     60  // -- we can rely on the collection (and therefore the build.cfg)
     61  // being here since this is the null protocol - a nicer way to
     62  // do this would be preferable though - Stefan.
     63  text_t buildtype = "mg"; // mg is default
     64  // (for now we'll just ignore mgpp if on windows)
     65#ifndef __WIN32__
     66  text_tarray cfgline;
     67  text_t key;
     68  text_t build_cfg = filename_cat(gsdlhome, "collect", collection, "index", "build.cfg");
     69  char *build_cfgc = build_cfg.getcstr();
     70  ifstream confin(build_cfgc);
     71
     72  if (confin) {
     73    while (read_cfg_line(confin, cfgline) >= 0) {
     74      if (cfgline.size() == 2) {
     75    key = cfgline[0];
     76    cfgline.erase(cfgline.begin());
     77    if (key == "buildtype") {
     78      buildtype = cfgline[0];
     79      break;
     80    }
     81      }
     82    }
     83    confin.close();
     84  }
     85  delete build_cfgc;
     86#endif
     87
     88  collectserver *cserver = new collectserver();
     89  gdbmclass *gdbmhandler = new gdbmclass();
     90
     91  // add a null filter
     92  filterclass *filter = new filterclass ();
     93  cserver->add_filter (filter);
     94     
     95  // add a browse filter
     96  browsefilterclass *browsefilter = new browsefilterclass();
     97  browsefilter->set_gdbmptr (gdbmhandler);
     98
     99  cserver->add_filter (browsefilter); 
     100 
     101  if (buildtype == "mg") {
     102    mgsearchclass *mgsearch = new mgsearchclass();
     103 
     104    // add a query filter
     105    mgqueryfilterclass *queryfilter = new mgqueryfilterclass();
     106    queryfilter->set_gdbmptr (gdbmhandler);
     107    queryfilter->set_mgsearchptr (mgsearch);
     108    cserver->add_filter (queryfilter);
     109   
     110    // add a mg and gdbm source
     111    mggdbmsourceclass *mggdbmsource = new mggdbmsourceclass ();
     112    mggdbmsource->set_gdbmptr (gdbmhandler);
     113    mggdbmsource->set_mgsearchptr (mgsearch);
     114    cserver->add_source (mggdbmsource);
     115  }
     116
     117#ifndef __WIN32__
     118
     119  else if (buildtype == "mgpp") {
     120     
     121    mgppsearchclass *mgsearch = new mgppsearchclass();
     122
     123    // add a query filter
     124    mgppqueryfilterclass *queryfilter = new mgppqueryfilterclass();
     125    queryfilter->set_gdbmptr (gdbmhandler);
     126    queryfilter->set_mgsearchptr (mgsearch);
     127    cserver->add_filter (queryfilter);
     128     
     129    // add a mg and gdbm source
     130    mggdbmsourceclass *mggdbmsource = new mggdbmsourceclass ();
     131    mggdbmsource->set_gdbmptr (gdbmhandler);
     132    mggdbmsource->set_mgsearchptr (mgsearch);
     133    cserver->add_source (mggdbmsource);
     134   
     135  }
     136#endif   
     137
     138  // inform collection server and everything it contains about its
     139  // collection name
     140  cserver->configure ("collection", collection);
     141 
     142  // configure receptionist's collectinfo structure
     143  text_tarray colinfo;
     144  colinfo.push_back (collection);
     145  colinfo.push_back (gsdlhome);
     146  colinfo.push_back (gdbmhome);
     147  receptionist *rcp = (receptionist *)recpt;
     148  rcp->configure ("collectinfo", colinfo);
     149 
     150  add_collectserver (cserver);
    41151}
    42152
  • trunk/gsdl/src/recpt/nullproto.h

    r1459 r1649  
    3131#include "collectserver.h"
    3232#include "recptproto.h"
    33 
     33#include "receptionist.h"
    3434
    3535class nullproto : public recptproto {
     
    3838public:
    3939  virtual ~nullproto();
     40
     41  // add_collection sets up the collectionserver and calls
     42  // add_collectserver
     43  void add_collection (const text_t &collection, void *recpt,
     44               const text_t &gsdlhome, const text_t &gdbmhome);
    4045
    4146  // add_collectserver should be called for each collection server
  • trunk/gsdl/src/recpt/recptproto.cpp

    r1285 r1649  
    2727#include <assert.h>
    2828
     29
     30// add collection server to protocol
     31void recptproto::add_collection (const text_t &/*collection*/, void * /*recpt*/,
     32                 const text_t &/*gsdlhome*/, const text_t &/*gdbmhome*/) {
     33}
    2934
    3035// configure should be called for each line in the configuration file
  • trunk/gsdl/src/recpt/recptproto.h

    r1285 r1649  
    5353class recptproto {
    5454public:
     55
     56  // add collection server to protocol
     57  virtual void add_collection (const text_t &collection, void *recpt,
     58                   const text_t &gsdlhome, const text_t &gdbmhome);
     59
    5560  // configure should be called for each line in the configuration file
    5661  virtual void configure (const text_t &key, const text_tarray &cfgline);
  • trunk/gsdl/src/w32server/cgiwrapper.cpp

    r1624 r1649  
    5454#include "receptionist.h"
    5555#include "nullproto.h"
    56 #include "collectserver.h"
    57 #include "infodbclass.h"
    58 #include "mggdbmsource.h"
    59 #include "mgsearch.h"
    6056
    6157// actions
     
    7975#include "pagedbrowserclass.h"
    8076#include "htmlbrowserclass.h"
    81 
    82 // filters
    83 #include "filter.h"
    84 #include "browsefilter.h"
    85 #include "mgqueryfilter.h"
    86 #include "phrasequeryfilter.h"
    8777
    8878// the number of times the library has been accessed
     
    396386
    397387  while (thiscol != endcol) {
    398 
    399     // this memory is created but never destroyed
    400     // we're also not doing any error checking to make sure we didn't
    401     // run out of memory
    402     collectserver *cserver = new collectserver();
    403     gdbmclass *gdbmhandler = new gdbmclass();
    404     mgsearchclass *mgsearch = new mgsearchclass();
    405    
    406     // add a null filter
    407     filterclass *filter = new filterclass();
    408     cserver->add_filter (filter);
    409    
    410     // add a browse filter
    411     browsefilterclass *browsefilter = new browsefilterclass();
    412     browsefilter->set_gdbmptr (gdbmhandler);
    413     cserver->add_filter (browsefilter);
    414    
    415     // add a query filter
    416     mgqueryfilterclass *queryfilter = new mgqueryfilterclass();
    417     queryfilter->set_gdbmptr (gdbmhandler);
    418     queryfilter->set_mgsearchptr (mgsearch);
    419     cserver->add_filter (queryfilter);
    420    
    421     // add an mg and gdbm source
    422     mggdbmsourceclass *mggdbmsource = new mggdbmsourceclass();
    423     mggdbmsource->set_gdbmptr (gdbmhandler);
    424     mggdbmsource->set_mgsearchptr (mgsearch);
    425     cserver->add_source (mggdbmsource);
    426    
    427     // inform collection server and everything it contains about
    428     // its collection name
    429     cserver->configure ("collection", *thiscol);
    430    
    431     nproto.add_collectserver (cserver);
     388   
     389    // ignore the modelcol
     390    if (*thiscol == "modelcol") {
     391      thiscol ++;
     392      continue;
     393    }
     394   
     395    // create collection server and add to null protocol
     396    nproto.add_collection (*thiscol, &recpt, gsdl_gsdlhome, gsdl_gsdlhome);
    432397   
    433398    thiscol ++;
Note: See TracChangeset for help on using the changeset viewer.