/********************************************************************** * * nullproto.cpp -- * Copyright (C) 1999 The New Zealand Digital Library Project * * A component of the Greenstone digital library software * from the New Zealand Digital Library Project at the * University of Waikato, New Zealand. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * *********************************************************************/ #include "nullproto.h" #include "colservrconfig.h" #include // this configure will configure each of the collection servers void nullproto::configure (const text_t &key, const text_tarray &cfgline) { // the naming of the collection should not be done here, // it should be done just after the collection server has been // created if (key == "collection" || key == "collectdir") return; collectservermapclass::iterator here = cservers.begin(); collectservermapclass::iterator end = cservers.end(); while (here != end) { assert ((*here).second.c != NULL); if ((*here).second.c != NULL) { if (key == "collectinfo") { if ((*here).first == cfgline[0]) { (*here).second.c->configure ("gsdlhome", cfgline[1]); (*here).second.c->configure ("gdbmhome", cfgline[2]); } } else { (*here).second.c->configure (key, cfgline); } } here++; } } // this init will configure and init each of the collection servers bool nullproto::init (ostream &logout) { collectservermapclass::iterator here = cservers.begin(); collectservermapclass::iterator end = cservers.end(); while (here != end) { assert ((*here).second.c != NULL); if ((*here).second.c != NULL) { const colservrconf &configinfo = (*here).second.c->get_configinfo (); // configure this collection server // note that we read build.cfg before collect.cfg so that the indexmaps // are available to decode defaultindex, defaultsubcollection, and // defaultlanguage if (!build_cfg_read (*((*here).second.c), configinfo.gsdlhome, configinfo.collection)) { outconvertclass text_t2ascii; logout << text_t2ascii << "Warning: couldn't read build.cfg file for collection \"" //**** << configinfo.collection << "\", gsdlhome=\"" << configinfo.gsdlhome << "\"\n"; // return false; //**** here ++; continue; } if (!collect_cfg_read (*((*here).second.c), configinfo.gsdlhome, configinfo.collection)) { outconvertclass text_t2ascii; logout << text_t2ascii << "Warning: couldn't read collect.cfg file for collection \"" << configinfo.collection << "\", gsdlhome=\"" << configinfo.gsdlhome << "\"\n"; // return false; //**** here ++; continue; } if (!(*here).second.c->init (logout)) return false; } here++; } return true; } text_t nullproto::get_protocol_name () { return "nullproto"; } void nullproto::get_collection_list (text_tarray &collist, comerror_t &err, ostream &/*logout*/) { collist.erase(collist.begin(),collist.end()); err = noError; collectservermapclass::iterator here = cservers.begin(); collectservermapclass::iterator end = cservers.end(); while (here != end) { assert ((*here).second.c != NULL); if ((*here).second.c != NULL) { collist.push_back ((*here).second.c->get_collection_name()); } here++; } } void nullproto::has_collection (const text_t &collection, bool &hascollection, comerror_t &err, ostream &/*logout*/) { hascollection = (cservers.getcollectserver(collection) != NULL); err = noError; } void nullproto::ping (const text_t &collection, bool &wassuccess, comerror_t &err, ostream &/*logout*/) { wassuccess = (cservers.getcollectserver(collection) != NULL); err = noError; } void nullproto::get_collectinfo (const text_t &collection, ColInfoResponse_t &collectinfo, comerror_t &err, ostream &logout) { collectserver *cserver = cservers.getcollectserver (collection); if (cserver != NULL) cserver->get_collectinfo (collectinfo, err, logout); else err = protocolError; } void nullproto::get_filterinfo (const text_t &collection, InfoFiltersResponse_t &response, comerror_t &err, ostream &logout) { collectserver *cserver = cservers.getcollectserver (collection); if (cserver != NULL) cserver->get_filterinfo (response, err, logout); else err = protocolError; } void nullproto::get_filteroptions (const text_t &collection, const InfoFilterOptionsRequest_t &request, InfoFilterOptionsResponse_t &response, comerror_t &err, ostream &logout) { collectserver *cserver = cservers.getcollectserver (collection); if (cserver != NULL) cserver->get_filteroptions (request, response, err, logout); else err = protocolError; } void nullproto::filter (const text_t &collection, FilterRequest_t &request, FilterResponse_t &response, comerror_t &err, ostream &logout) { collectserver *cserver = cservers.getcollectserver (collection); if (cserver != NULL) cserver->filter (request, response, err, logout); else err = protocolError; } void nullproto::get_document (const text_t &collection, const DocumentRequest_t &request, DocumentResponse_t &response, comerror_t &err, ostream &logout) { collectserver *cserver = cservers.getcollectserver (collection); if (cserver != NULL) cserver->get_document (request, response, err, logout); else err = protocolError; }