[166] | 1 | /**********************************************************************
|
---|
| 2 | *
|
---|
| 3 | * nullproto.cpp --
|
---|
| 4 | * Copyright (C) 1999 The New Zealand Digital Library Project
|
---|
| 5 | *
|
---|
[533] | 6 | * A component of the Greenstone digital library software
|
---|
| 7 | * from the New Zealand Digital Library Project at the
|
---|
| 8 | * University of Waikato, New Zealand.
|
---|
[166] | 9 | *
|
---|
[533] | 10 | * This program is free software; you can redistribute it and/or modify
|
---|
| 11 | * it under the terms of the GNU General Public License as published by
|
---|
| 12 | * the Free Software Foundation; either version 2 of the License, or
|
---|
| 13 | * (at your option) any later version.
|
---|
| 14 | *
|
---|
| 15 | * This program is distributed in the hope that it will be useful,
|
---|
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 18 | * GNU General Public License for more details.
|
---|
| 19 | *
|
---|
| 20 | * You should have received a copy of the GNU General Public License
|
---|
| 21 | * along with this program; if not, write to the Free Software
|
---|
| 22 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
| 23 | *
|
---|
[166] | 24 | *********************************************************************/
|
---|
| 25 |
|
---|
| 26 | #include "nullproto.h"
|
---|
| 27 | #include "colservrconfig.h"
|
---|
| 28 | #include <assert.h>
|
---|
| 29 |
|
---|
| 30 |
|
---|
| 31 | // this configure will configure each of the collection servers
|
---|
| 32 | void nullproto::configure (const text_t &key, const text_tarray &cfgline) {
|
---|
| 33 | // the naming of the collection should not be done here,
|
---|
| 34 | // it should be done just after the collection server has been
|
---|
| 35 | // created
|
---|
[269] | 36 | if (key == "collection" || key == "collectdir") return;
|
---|
[166] | 37 |
|
---|
| 38 | collectservermapclass::iterator here = cservers.begin();
|
---|
| 39 | collectservermapclass::iterator end = cservers.end();
|
---|
| 40 |
|
---|
| 41 | while (here != end) {
|
---|
| 42 | assert ((*here).second.c != NULL);
|
---|
| 43 | if ((*here).second.c != NULL) {
|
---|
[801] | 44 | if (key == "collectinfo") {
|
---|
| 45 | if ((*here).first == cfgline[0]) {
|
---|
| 46 | (*here).second.c->configure ("gsdlhome", cfgline[1]);
|
---|
| 47 | (*here).second.c->configure ("gdbmhome", cfgline[2]);
|
---|
| 48 | }
|
---|
| 49 | } else {
|
---|
| 50 | (*here).second.c->configure (key, cfgline);
|
---|
| 51 | }
|
---|
[166] | 52 | }
|
---|
| 53 |
|
---|
| 54 | here++;
|
---|
| 55 | }
|
---|
| 56 | }
|
---|
| 57 |
|
---|
| 58 | // this init will configure and init each of the collection servers
|
---|
| 59 | bool nullproto::init (ostream &logout) {
|
---|
| 60 | collectservermapclass::iterator here = cservers.begin();
|
---|
| 61 | collectservermapclass::iterator end = cservers.end();
|
---|
| 62 |
|
---|
| 63 | while (here != end) {
|
---|
| 64 | assert ((*here).second.c != NULL);
|
---|
| 65 | if ((*here).second.c != NULL) {
|
---|
| 66 | const colservrconf &configinfo = (*here).second.c->get_configinfo ();
|
---|
| 67 |
|
---|
| 68 | // configure this collection server
|
---|
[299] | 69 |
|
---|
| 70 | // note that we read build.cfg before collect.cfg so that the indexmaps
|
---|
| 71 | // are available to decode defaultindex, defaultsubcollection, and
|
---|
| 72 | // defaultlanguage
|
---|
| 73 | if (!build_cfg_read (*((*here).second.c), configinfo.gsdlhome,
|
---|
| 74 | configinfo.collection)) {
|
---|
[166] | 75 | outconvertclass text_t2ascii;
|
---|
| 76 | logout << text_t2ascii
|
---|
[722] | 77 | << "Warning: couldn't read build.cfg file for collection \"" //****
|
---|
[299] | 78 | << configinfo.collection << "\", gsdlhome=\""
|
---|
[166] | 79 | << configinfo.gsdlhome << "\"\n";
|
---|
[722] | 80 | // return false; //****
|
---|
[746] | 81 | here ++;
|
---|
| 82 | continue;
|
---|
[166] | 83 | }
|
---|
| 84 |
|
---|
[299] | 85 | if (!collect_cfg_read (*((*here).second.c), configinfo.gsdlhome,
|
---|
| 86 | configinfo.collection)) {
|
---|
[166] | 87 | outconvertclass text_t2ascii;
|
---|
| 88 | logout << text_t2ascii
|
---|
[746] | 89 | << "Warning: couldn't read collect.cfg file for collection \""
|
---|
[299] | 90 | << configinfo.collection << "\", gsdlhome=\""
|
---|
[166] | 91 | << configinfo.gsdlhome << "\"\n";
|
---|
[746] | 92 | // return false; //****
|
---|
| 93 | here ++;
|
---|
| 94 | continue;
|
---|
[166] | 95 | }
|
---|
| 96 |
|
---|
| 97 | if (!(*here).second.c->init (logout)) return false;
|
---|
| 98 | }
|
---|
| 99 | here++;
|
---|
| 100 | }
|
---|
| 101 |
|
---|
| 102 | return true;
|
---|
| 103 | }
|
---|
| 104 |
|
---|
| 105 | text_t nullproto::get_protocol_name () {
|
---|
| 106 | return "nullproto";
|
---|
| 107 | }
|
---|
| 108 |
|
---|
| 109 |
|
---|
| 110 | void nullproto::get_collection_list (text_tarray &collist, comerror_t &err,
|
---|
| 111 | ostream &/*logout*/) {
|
---|
[172] | 112 | collist.erase(collist.begin(),collist.end());
|
---|
[166] | 113 | err = noError;
|
---|
| 114 |
|
---|
| 115 | collectservermapclass::iterator here = cservers.begin();
|
---|
| 116 | collectservermapclass::iterator end = cservers.end();
|
---|
| 117 | while (here != end) {
|
---|
| 118 | assert ((*here).second.c != NULL);
|
---|
| 119 | if ((*here).second.c != NULL) {
|
---|
| 120 | collist.push_back ((*here).second.c->get_collection_name());
|
---|
| 121 | }
|
---|
| 122 | here++;
|
---|
| 123 | }
|
---|
| 124 | }
|
---|
| 125 |
|
---|
| 126 | void nullproto::has_collection (const text_t &collection, bool &hascollection,
|
---|
| 127 | comerror_t &err, ostream &/*logout*/) {
|
---|
| 128 | hascollection = (cservers.getcollectserver(collection) != NULL);
|
---|
| 129 | err = noError;
|
---|
| 130 | }
|
---|
| 131 |
|
---|
| 132 | void nullproto::ping (const text_t &collection, bool &wassuccess,
|
---|
| 133 | comerror_t &err, ostream &/*logout*/) {
|
---|
| 134 | wassuccess = (cservers.getcollectserver(collection) != NULL);
|
---|
| 135 | err = noError;
|
---|
| 136 | }
|
---|
| 137 |
|
---|
| 138 | void nullproto::get_collectinfo (const text_t &collection,
|
---|
| 139 | ColInfoResponse_t &collectinfo,
|
---|
[184] | 140 | comerror_t &err, ostream &logout) {
|
---|
[166] | 141 | collectserver *cserver = cservers.getcollectserver (collection);
|
---|
[184] | 142 | if (cserver != NULL) cserver->get_collectinfo (collectinfo, err, logout);
|
---|
| 143 | else err = protocolError;
|
---|
| 144 | }
|
---|
[166] | 145 |
|
---|
[184] | 146 |
|
---|
[220] | 147 | void nullproto::get_filterinfo (const text_t &collection,
|
---|
| 148 | InfoFiltersResponse_t &response,
|
---|
| 149 | comerror_t &err, ostream &logout) {
|
---|
| 150 | collectserver *cserver = cservers.getcollectserver (collection);
|
---|
| 151 | if (cserver != NULL) cserver->get_filterinfo (response, err, logout);
|
---|
| 152 | else err = protocolError;
|
---|
| 153 | }
|
---|
| 154 |
|
---|
[184] | 155 | void nullproto::get_filteroptions (const text_t &collection,
|
---|
[220] | 156 | const InfoFilterOptionsRequest_t &request,
|
---|
[184] | 157 | InfoFilterOptionsResponse_t &response,
|
---|
| 158 | comerror_t &err, ostream &logout) {
|
---|
| 159 | collectserver *cserver = cservers.getcollectserver (collection);
|
---|
[220] | 160 | if (cserver != NULL) cserver->get_filteroptions (request, response, err, logout);
|
---|
[184] | 161 | else err = protocolError;
|
---|
[166] | 162 | }
|
---|
[184] | 163 |
|
---|
| 164 | void nullproto::filter (const text_t &collection,
|
---|
[248] | 165 | FilterRequest_t &request,
|
---|
[184] | 166 | FilterResponse_t &response,
|
---|
| 167 | comerror_t &err, ostream &logout) {
|
---|
| 168 | collectserver *cserver = cservers.getcollectserver (collection);
|
---|
| 169 | if (cserver != NULL) cserver->filter (request, response, err, logout);
|
---|
| 170 | else err = protocolError;
|
---|
| 171 | }
|
---|
| 172 |
|
---|
[257] | 173 | void nullproto::get_document (const text_t &collection,
|
---|
| 174 | const DocumentRequest_t &request,
|
---|
| 175 | DocumentResponse_t &response,
|
---|
| 176 | comerror_t &err, ostream &logout) {
|
---|
| 177 | collectserver *cserver = cservers.getcollectserver (collection);
|
---|
| 178 | if (cserver != NULL) cserver->get_document (request, response, err, logout);
|
---|
| 179 | else err = protocolError;
|
---|
| 180 | }
|
---|