[226] | 1 |
|
---|
[166] | 2 | /**********************************************************************
|
---|
| 3 | *
|
---|
| 4 | * collectserver.cpp --
|
---|
| 5 | * Copyright (C) 1999 The New Zealand Digital Library Project
|
---|
| 6 | *
|
---|
[534] | 7 | * A component of the Greenstone digital library software
|
---|
| 8 | * from the New Zealand Digital Library Project at the
|
---|
| 9 | * University of Waikato, New Zealand.
|
---|
[166] | 10 | *
|
---|
[534] | 11 | * This program is free software; you can redistribute it and/or modify
|
---|
| 12 | * it under the terms of the GNU General Public License as published by
|
---|
| 13 | * the Free Software Foundation; either version 2 of the License, or
|
---|
| 14 | * (at your option) any later version.
|
---|
| 15 | *
|
---|
| 16 | * This program is distributed in the hope that it will be useful,
|
---|
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 19 | * GNU General Public License for more details.
|
---|
| 20 | *
|
---|
| 21 | * You should have received a copy of the GNU General Public License
|
---|
| 22 | * along with this program; if not, write to the Free Software
|
---|
| 23 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
| 24 | *
|
---|
[166] | 25 | *********************************************************************/
|
---|
| 26 |
|
---|
| 27 | #include "collectserver.h"
|
---|
[249] | 28 | #include "OIDtools.h"
|
---|
[166] | 29 | #include <assert.h>
|
---|
[9929] | 30 | #include "display.h"
|
---|
[166] | 31 |
|
---|
| 32 |
|
---|
| 33 | collectserver::collectserver () {
|
---|
| 34 | configinfo.collection = "null";
|
---|
| 35 | }
|
---|
| 36 |
|
---|
| 37 | collectserver::~collectserver () {
|
---|
[1459] | 38 |
|
---|
| 39 | // clean up the sources
|
---|
| 40 | sourcelistclass::iterator source_here = sources.begin();
|
---|
| 41 | sourcelistclass::iterator source_end = sources.end();
|
---|
| 42 | while (source_here != source_end) {
|
---|
| 43 | if ((*source_here).s != NULL)
|
---|
| 44 | delete (*source_here).s;
|
---|
[9620] | 45 | ++source_here;
|
---|
[1459] | 46 | }
|
---|
| 47 | sources.clear();
|
---|
| 48 |
|
---|
| 49 | // clean up the filters
|
---|
| 50 | filtermapclass::iterator filter_here = filters.begin();
|
---|
| 51 | filtermapclass::iterator filter_end = filters.end();
|
---|
| 52 | while (filter_here != filter_end) {
|
---|
| 53 | if ((*filter_here).second.f != NULL)
|
---|
| 54 | delete (*filter_here).second.f;
|
---|
[9620] | 55 | ++filter_here;
|
---|
[1459] | 56 | }
|
---|
| 57 | filters.clear();
|
---|
[166] | 58 | }
|
---|
| 59 |
|
---|
| 60 | // configure should be called for each line in the
|
---|
| 61 | // configuration files to configure the collection server and everything
|
---|
[13982] | 62 | // it contains. The configuration should take place just before initialisationhttps://www.google.com/accounts/ServiceLogin?service=mail&passive=true&rm=false&continue=http%3A%2F%2Fmail.google.com%2Fmail%3Fui%3Dhtml%26zy%3Dl<mpl=ca_tlsosm_video<mplcache=2&hl=en.
|
---|
[166] | 63 | void collectserver::configure (const text_t &key, const text_tarray &cfgline) {
|
---|
[226] | 64 | if (cfgline.size() >= 1) {
|
---|
[166] | 65 | const text_t &value = cfgline[0];
|
---|
[13982] | 66 | if (key == "plugin")
|
---|
| 67 | {
|
---|
| 68 | //get the plugin name
|
---|
| 69 | const text_t &name = cfgline[0];
|
---|
| 70 |
|
---|
| 71 | if (name == "HTMLPlug")
|
---|
| 72 | {
|
---|
| 73 | for (int hI = 1; hI < cfgline.size(); hI++)
|
---|
| 74 | {
|
---|
| 75 | const text_t &plugOption = cfgline[hI];
|
---|
| 76 |
|
---|
| 77 | if (plugOption == "-tidy_html")
|
---|
| 78 | {
|
---|
| 79 | collectinfo.useBook = true;
|
---|
| 80 | break;
|
---|
| 81 | }
|
---|
| 82 | }
|
---|
| 83 | }
|
---|
| 84 | }
|
---|
| 85 | else if (key == "gsdlhome") configinfo.gsdlhome = value;
|
---|
[15587] | 86 | else if (key == "gdbmhome") configinfo.dbhome = value;
|
---|
[166] | 87 | else if (key == "collection") {
|
---|
| 88 | configinfo.collection = value;
|
---|
| 89 | collectinfo.shortInfo.name = value;
|
---|
| 90 | } else if (key == "collectdir") configinfo.collectdir = value;
|
---|
| 91 | else if (key == "host") collectinfo.shortInfo.host = value;
|
---|
| 92 | else if (key == "port") collectinfo.shortInfo.port = value.getint();
|
---|
| 93 | else if (key == "public") {
|
---|
| 94 | if (value == "true") collectinfo.isPublic = true;
|
---|
| 95 | else collectinfo.isPublic = false;
|
---|
| 96 | } else if (key == "beta") {
|
---|
| 97 | if (value == "true") collectinfo.isBeta = true;
|
---|
| 98 | else collectinfo.isBeta = false;
|
---|
[15002] | 99 | } else if (key == "collectgroup") {
|
---|
| 100 | if (value == "true") collectinfo.isCollectGroup = true;
|
---|
| 101 | else collectinfo.isCollectGroup = false;
|
---|
[2712] | 102 | } else if ((key == "ccscols") || (key == "supercollection")) collectinfo.ccsCols = cfgline;
|
---|
[10789] | 103 | else if (key == "supercollectionoptions") {
|
---|
| 104 | text_tarray::const_iterator begin = cfgline.begin();
|
---|
| 105 | text_tarray::const_iterator end = cfgline.end();
|
---|
| 106 | while(begin != end) {
|
---|
| 107 |
|
---|
| 108 | if (*begin == "uniform_search_results_formatting") {
|
---|
| 109 | collectinfo.ccsOptions |= CCSUniformSearchResultsFormatting;
|
---|
| 110 | }
|
---|
| 111 | begin++;
|
---|
| 112 | }
|
---|
| 113 | }
|
---|
[830] | 114 | else if (key == "builddate") collectinfo.buildDate = value.getint();
|
---|
[166] | 115 | else if (key == "languages") collectinfo.languages = cfgline;
|
---|
| 116 | else if (key == "numdocs") collectinfo.numDocs = value.getint();
|
---|
[1253] | 117 | else if (key == "numsections") collectinfo.numSections = value.getint();
|
---|
[166] | 118 | else if (key == "numwords") collectinfo.numWords = value.getint();
|
---|
| 119 | else if (key == "numbytes") collectinfo.numBytes = value.getint();
|
---|
[12867] | 120 | else if (key == "stemindexes") collectinfo.stemIndexes = value.getint();
|
---|
[8453] | 121 | else if (key == "collectionmeta") {
|
---|
[11964] | 122 | // genuine collmeta get added as collectionmeta and collection_macros
|
---|
| 123 | // .collmeta just get added as collection_macros
|
---|
[9929] | 124 | text_t params;
|
---|
| 125 | if (cfgline.size() == 3) {
|
---|
| 126 | // get the params for later
|
---|
| 127 | text_t::const_iterator first=cfgline[1].begin()+1;
|
---|
| 128 | text_t::const_iterator last=cfgline[1].end()-1;
|
---|
| 129 | params=substr(first, last);
|
---|
| 130 | }
|
---|
| 131 |
|
---|
| 132 | text_t meta_name = cfgline[0];
|
---|
| 133 | if (*(meta_name.begin())=='.') {
|
---|
| 134 | // a .xxx collectionmeta. strip off the . and
|
---|
| 135 | // look it up in the indexmap to get the actual value
|
---|
| 136 |
|
---|
| 137 | text_t name = substr(cfgline[0].begin()+1,cfgline[0].end());
|
---|
| 138 | text_t new_name;
|
---|
| 139 | if (indexmap.from2to(name, new_name)) {
|
---|
| 140 | meta_name = new_name;
|
---|
| 141 | }
|
---|
| 142 | } else {
|
---|
| 143 | // add them to collectionmeta
|
---|
| 144 | text_tmap lang_map = collectinfo.collectionmeta[cfgline[0]];
|
---|
| 145 | if (cfgline.size() == 2) {
|
---|
| 146 | lang_map[g_EmptyText] = cfgline[1];
|
---|
| 147 | } else if (cfgline.size() == 3 ) {
|
---|
| 148 | // get the lang out of params
|
---|
| 149 | paramhashtype params_hash;
|
---|
| 150 | splitparams(params, params_hash);
|
---|
| 151 |
|
---|
| 152 | text_t lang = params_hash["l"];
|
---|
| 153 | lang_map[lang] = cfgline[2];
|
---|
| 154 | if (lang_map[g_EmptyText].empty()) {
|
---|
| 155 | // want the first one as the default if no default specified
|
---|
| 156 | lang_map[g_EmptyText] = cfgline[2];
|
---|
| 157 | }
|
---|
| 158 | }
|
---|
| 159 | collectinfo.collectionmeta[cfgline[0]] = lang_map;
|
---|
| 160 |
|
---|
| 161 | }
|
---|
| 162 |
|
---|
| 163 | // add all collectionmeta to macro list
|
---|
[11964] | 164 | text_tmap params_map = collectinfo.collection_macros[meta_name];
|
---|
| 165 |
|
---|
[13982] | 166 | if (cfgline.size() == 2) {// no params for this macrohttp://uk.sports.yahoo.com/13032007/13/news-brief.html
|
---|
[11964] | 167 | params_map[g_EmptyText] = cfgline[1];
|
---|
| 168 | }
|
---|
[9929] | 169 | else if (cfgline.size() == 3) {// has params
|
---|
[11964] | 170 | params_map[params] = cfgline[2];
|
---|
| 171 | if (params_map[g_EmptyText].empty()) {
|
---|
| 172 | params_map[g_EmptyText] = cfgline[2];
|
---|
| 173 | }
|
---|
[9929] | 174 | }
|
---|
[11964] | 175 | collectinfo.collection_macros[meta_name] = params_map;
|
---|
[9929] | 176 | }
|
---|
| 177 | else if (key == "collectionmacro") {
|
---|
| 178 | text_t nobrackets;
|
---|
[11964] | 179 | text_tmap params_map = collectinfo.collection_macros[cfgline[0]];
|
---|
[9929] | 180 | // add all to macro list
|
---|
[11964] | 181 | if (cfgline.size() == 2) { // no params for this macro
|
---|
| 182 | params_map[g_EmptyText] = cfgline[1];
|
---|
| 183 | }
|
---|
[8453] | 184 | else if (cfgline.size() == 3) {// has params
|
---|
| 185 | // strip [ ] brackets from params
|
---|
| 186 | text_t::const_iterator first=cfgline[1].begin()+1;
|
---|
| 187 | text_t::const_iterator last=cfgline[1].end()-1;
|
---|
[9929] | 188 | nobrackets=substr(first, last);
|
---|
[11964] | 189 | params_map[nobrackets] = cfgline[2];
|
---|
[8453] | 190 | }
|
---|
[11964] | 191 | collectinfo.collection_macros[cfgline[0]] = params_map;
|
---|
| 192 |
|
---|
[8453] | 193 | } else if (key == "format" && cfgline.size() == 2)
|
---|
[352] | 194 | collectinfo.format[cfgline[0]] = cfgline[1];
|
---|
[722] | 195 | else if (key == "building" && cfgline.size() == 2)
|
---|
| 196 | collectinfo.building[cfgline[0]] = cfgline[1];
|
---|
[1860] | 197 | else if (key == "httpdomain") collectinfo.httpdomain = value;
|
---|
| 198 | else if (key == "httpprefix") collectinfo.httpprefix = value;
|
---|
[432] | 199 | else if (key == "receptionist") collectinfo.receptionist = value;
|
---|
[1318] | 200 | else if (key == "buildtype") collectinfo.buildType = value;
|
---|
[11984] | 201 | // backwards compatibility - searchytpes is now a format statement
|
---|
[4751] | 202 | else if (key == "searchtype") { // means buildtype is mgpp
|
---|
[9904] | 203 | if (collectinfo.buildType.empty()) {
|
---|
| 204 | collectinfo.buildType = "mgpp";
|
---|
| 205 | }
|
---|
[11984] | 206 | joinchar(cfgline, ',', collectinfo.format["SearchTypes"]);
|
---|
| 207 | //collectinfo.searchTypes = cfgline;
|
---|
[4751] | 208 | }
|
---|
[6584] | 209 | else if (key == "separate_cjk") {
|
---|
| 210 | if (value == "true") collectinfo.isSegmented = true;
|
---|
| 211 | else collectinfo.isSegmented = false;
|
---|
| 212 | }
|
---|
[4974] | 213 | // What have we set in our collect.cfg file : document or collection ?
|
---|
[5024] | 214 | else if (key == "authenticate") collectinfo.authenticate = value;
|
---|
[4974] | 215 |
|
---|
| 216 | // What have we set for our group list
|
---|
[11984] | 217 | else if (key == "auth_group") joinchar(cfgline,',',collectinfo.auth_group);
|
---|
[4974] | 218 |
|
---|
[9929] | 219 | // store all the mappings for use when collection meta is read later
|
---|
| 220 | // (build.cfg read before collect.cfg)
|
---|
[9934] | 221 | else if (key == "indexmap" || key == "indexfieldmap" || key == "subcollectionmap" || key == "languagemap" || key == "levelmap") {
|
---|
[9929] | 222 | indexmap.importmap (cfgline, true);
|
---|
| 223 |
|
---|
| 224 | }
|
---|
[4974] | 225 | // In the map the key-value pair contain the same
|
---|
[5024] | 226 | // data i.e key == data, if key is 2 then data is 2
|
---|
[4974] | 227 |
|
---|
[5024] | 228 | // What have we set for our public_documents ACL
|
---|
| 229 | else if (key == "public_documents")
|
---|
[4974] | 230 | {
|
---|
| 231 | text_tarray::const_iterator begin = cfgline.begin();
|
---|
| 232 | text_tarray::const_iterator end = cfgline.end();
|
---|
| 233 | while(begin != end)
|
---|
| 234 | {
|
---|
[5024] | 235 | // key = data i.e if key is 2 then data is 2
|
---|
| 236 | // collectinfo.public_documents[*begin] is the key
|
---|
| 237 | // *begin is the data value
|
---|
| 238 |
|
---|
| 239 | collectinfo.public_documents[*begin] = *begin;
|
---|
[9620] | 240 | ++begin;
|
---|
[4974] | 241 | }
|
---|
| 242 | }
|
---|
| 243 |
|
---|
[5024] | 244 | // What have we set for our private_documents ACL
|
---|
| 245 | else if (key == "private_documents")
|
---|
[4974] | 246 | {
|
---|
| 247 | text_tarray::const_iterator begin = cfgline.begin();
|
---|
| 248 | text_tarray::const_iterator end = cfgline.end();
|
---|
| 249 | while(begin != end)
|
---|
| 250 | {
|
---|
[5024] | 251 | // key = data i.e if key is 2 then data is 2
|
---|
| 252 | // collectinfo.public_documents[*begin] is the key
|
---|
| 253 | // *begin is the data value
|
---|
| 254 |
|
---|
| 255 | collectinfo.private_documents[*begin] = *begin;
|
---|
[9620] | 256 | ++begin;
|
---|
[4974] | 257 | }
|
---|
| 258 | }
|
---|
[226] | 259 | }
|
---|
[9929] | 260 |
|
---|
[226] | 261 | // configure the filters
|
---|
| 262 | filtermapclass::iterator filter_here = filters.begin();
|
---|
| 263 | filtermapclass::iterator filter_end = filters.end();
|
---|
| 264 | while (filter_here != filter_end) {
|
---|
| 265 | assert ((*filter_here).second.f != NULL);
|
---|
| 266 | if ((*filter_here).second.f != NULL)
|
---|
| 267 | (*filter_here).second.f->configure(key, cfgline);
|
---|
[191] | 268 |
|
---|
[9620] | 269 | ++filter_here;
|
---|
[166] | 270 | }
|
---|
[226] | 271 |
|
---|
| 272 | // configure the sources
|
---|
| 273 | sourcelistclass::iterator source_here = sources.begin();
|
---|
| 274 | sourcelistclass::iterator source_end = sources.end();
|
---|
| 275 | while (source_here != source_end) {
|
---|
| 276 | assert ((*source_here).s != NULL);
|
---|
| 277 | if ((*source_here).s != NULL)
|
---|
| 278 | (*source_here).s->configure(key, cfgline);
|
---|
| 279 |
|
---|
[9620] | 280 | ++source_here;
|
---|
[226] | 281 | }
|
---|
[166] | 282 | }
|
---|
| 283 |
|
---|
[9929] | 284 |
|
---|
[166] | 285 | void collectserver::configure (const text_t &key, const text_t &value) {
|
---|
| 286 | text_tarray cfgline;
|
---|
| 287 | cfgline.push_back (value);
|
---|
| 288 | configure(key, cfgline);
|
---|
| 289 | }
|
---|
| 290 |
|
---|
[2173] | 291 | void collectserver::ping (bool &wasSuccess, comerror_t &error, ostream &logout) {
|
---|
| 292 | // if we've not been properly configured, then it is a foregone
|
---|
| 293 | // conclusion that we cannot be active
|
---|
| 294 | if (this->configinfo.collection == "null")
|
---|
| 295 | {
|
---|
| 296 | wasSuccess = false;
|
---|
| 297 | }
|
---|
| 298 | // if no build date exists, then the collection was probably not built;
|
---|
| 299 | // ditto if the number of documents is zero, then something is pretty
|
---|
| 300 | // wrong
|
---|
| 301 | else if (this->collectinfo.buildDate == 0 ||
|
---|
| 302 | this->collectinfo.numDocs == 0)
|
---|
| 303 | {
|
---|
| 304 | wasSuccess = false;
|
---|
| 305 | }
|
---|
| 306 | // it is probably okay
|
---|
| 307 | else
|
---|
| 308 | wasSuccess = true;
|
---|
| 309 | }
|
---|
[166] | 310 |
|
---|
[2173] | 311 |
|
---|
[226] | 312 | bool collectserver::init (ostream &logout) {
|
---|
[9929] | 313 | // delete the indexmap
|
---|
| 314 | indexmap.clear();
|
---|
| 315 |
|
---|
[226] | 316 | // init the filters
|
---|
| 317 | filtermapclass::iterator filter_here = filters.begin();
|
---|
| 318 | filtermapclass::iterator filter_end = filters.end();
|
---|
| 319 | while (filter_here != filter_end) {
|
---|
| 320 | assert ((*filter_here).second.f != NULL);
|
---|
| 321 | if (((*filter_here).second.f != NULL) &&
|
---|
| 322 | !(*filter_here).second.f->init(logout)) return false;
|
---|
| 323 |
|
---|
[9620] | 324 | ++filter_here;
|
---|
[226] | 325 | }
|
---|
| 326 |
|
---|
| 327 | // init the sources
|
---|
| 328 | sourcelistclass::iterator source_here = sources.begin();
|
---|
| 329 | sourcelistclass::iterator source_end = sources.end();
|
---|
| 330 | while (source_here != source_end) {
|
---|
| 331 | assert ((*source_here).s != NULL);
|
---|
| 332 | if (((*source_here).s != NULL) &&
|
---|
| 333 | !(*source_here).s->init(logout)) return false;
|
---|
| 334 |
|
---|
[9620] | 335 | ++source_here;
|
---|
[226] | 336 | }
|
---|
| 337 |
|
---|
[166] | 338 | return true;
|
---|
| 339 | }
|
---|
| 340 |
|
---|
| 341 |
|
---|
[186] | 342 | void collectserver::get_collectinfo (ColInfoResponse_t &reponse,
|
---|
| 343 | comerror_t &err, ostream &/*logout*/) {
|
---|
| 344 | reponse = collectinfo;
|
---|
| 345 | err = noError;
|
---|
| 346 | }
|
---|
[166] | 347 |
|
---|
[226] | 348 | void collectserver::get_filterinfo (InfoFiltersResponse_t &response,
|
---|
[220] | 349 | comerror_t &err, ostream &/*logout*/) {
|
---|
[226] | 350 | response.clear ();
|
---|
| 351 |
|
---|
| 352 | // get a list of filter names
|
---|
| 353 | filtermapclass::iterator filter_here = filters.begin();
|
---|
| 354 | filtermapclass::iterator filter_end = filters.end();
|
---|
| 355 | while (filter_here != filter_end) {
|
---|
| 356 | response.filterNames.insert ((*filter_here).first);
|
---|
[9745] | 357 | ++filter_here;
|
---|
[226] | 358 | }
|
---|
| 359 |
|
---|
| 360 | err = noError;
|
---|
[220] | 361 | }
|
---|
| 362 |
|
---|
[226] | 363 | void collectserver::get_filteroptions (const InfoFilterOptionsRequest_t &request,
|
---|
[220] | 364 | InfoFilterOptionsResponse_t &response,
|
---|
[226] | 365 | comerror_t &err, ostream &logout) {
|
---|
| 366 | outconvertclass text_t2ascii;
|
---|
| 367 |
|
---|
| 368 | filterclass *thisfilter = filters.getfilter(request.filterName);
|
---|
| 369 | if (thisfilter != NULL) {
|
---|
| 370 | thisfilter->get_filteroptions (response, err, logout);
|
---|
| 371 | } else {
|
---|
| 372 | response.clear ();
|
---|
| 373 | err = protocolError;
|
---|
| 374 | logout << text_t2ascii << "Protocol Error: filter options requested for non-existent\n"
|
---|
| 375 | << "filter \"" << request.filterName << "\".\n\n";
|
---|
| 376 | }
|
---|
[186] | 377 | }
|
---|
| 378 |
|
---|
[249] | 379 | void collectserver::filter (FilterRequest_t &request,
|
---|
[186] | 380 | FilterResponse_t &response,
|
---|
[226] | 381 | comerror_t &err, ostream &logout) {
|
---|
| 382 | outconvertclass text_t2ascii;
|
---|
| 383 |
|
---|
[249] | 384 | // translate any ".fc", ".pr" etc. stuff in the docSet
|
---|
| 385 | text_t translatedOID;
|
---|
[472] | 386 | text_tarray translatedOIDs;
|
---|
| 387 | text_tarray::iterator doc_here = request.docSet.begin();
|
---|
| 388 | text_tarray::iterator doc_end = request.docSet.end();
|
---|
[249] | 389 | while (doc_here != doc_end) {
|
---|
| 390 | if (needs_translating (*doc_here)) {
|
---|
| 391 | sourcelistclass::iterator source_here = sources.begin();
|
---|
| 392 | sourcelistclass::iterator source_end = sources.end();
|
---|
| 393 | while (source_here != source_end) {
|
---|
| 394 | assert ((*source_here).s != NULL);
|
---|
| 395 | if (((*source_here).s != NULL) &&
|
---|
| 396 | ((*source_here).s->translate_OID (*doc_here, translatedOID, err, logout))) {
|
---|
| 397 | if (err != noError) return;
|
---|
| 398 | break;
|
---|
| 399 | }
|
---|
[9620] | 400 | ++source_here;
|
---|
[249] | 401 | }
|
---|
[472] | 402 | translatedOIDs.push_back (translatedOID);
|
---|
[249] | 403 | } else {
|
---|
[472] | 404 | translatedOIDs.push_back (*doc_here);
|
---|
[249] | 405 | }
|
---|
[9620] | 406 | ++doc_here;
|
---|
[249] | 407 | }
|
---|
| 408 | request.docSet = translatedOIDs;
|
---|
| 409 |
|
---|
[196] | 410 | response.clear();
|
---|
[650] | 411 |
|
---|
[226] | 412 | filterclass *thisfilter = filters.getfilter(request.filterName);
|
---|
| 413 | if (thisfilter != NULL) {
|
---|
| 414 | // filter the data
|
---|
| 415 | thisfilter->filter (request, response, err, logout);
|
---|
[4216] | 416 | if (err != noError) return;
|
---|
[226] | 417 | // fill in the metadata for each of the OIDs (if it is requested)
|
---|
| 418 | if (request.filterResultOptions & FRmetadata) {
|
---|
[466] | 419 | bool processed = false;
|
---|
[226] | 420 | ResultDocInfo_tarray::iterator resultdoc_here = response.docInfo.begin();
|
---|
| 421 | ResultDocInfo_tarray::iterator resultdoc_end = response.docInfo.end();
|
---|
| 422 | while (resultdoc_here != resultdoc_end) {
|
---|
| 423 | // try each of the sources in turn
|
---|
| 424 | sourcelistclass::iterator source_here = sources.begin();
|
---|
| 425 | sourcelistclass::iterator source_end = sources.end();
|
---|
| 426 | while (source_here != source_end) {
|
---|
| 427 | assert ((*source_here).s != NULL);
|
---|
| 428 | if (((*source_here).s != NULL) &&
|
---|
| 429 | ((*source_here).s->get_metadata(request.requestParams, request.refParams,
|
---|
[271] | 430 | request.getParents, request.fields,
|
---|
| 431 | (*resultdoc_here).OID, (*resultdoc_here).metadata,
|
---|
| 432 | err, logout))) {
|
---|
[226] | 433 | if (err != noError) return;
|
---|
[466] | 434 | processed = true;
|
---|
[226] | 435 | break;
|
---|
| 436 | }
|
---|
[9620] | 437 | ++source_here;
|
---|
[226] | 438 | }
|
---|
[466] | 439 | if (!processed) {
|
---|
[12018] | 440 |
|
---|
| 441 | logout << text_t2ascii << "Protocol Error: nothing processed for "
|
---|
| 442 | << "filter \"" << request.filterName << "\".\n\n";
|
---|
| 443 |
|
---|
[466] | 444 | err = protocolError;
|
---|
| 445 | return;
|
---|
| 446 | }
|
---|
[9620] | 447 | ++resultdoc_here;
|
---|
[226] | 448 | }
|
---|
| 449 | }
|
---|
[196] | 450 |
|
---|
[191] | 451 | } else {
|
---|
[226] | 452 | response.clear ();
|
---|
[196] | 453 | err = protocolError;
|
---|
[226] | 454 | logout << text_t2ascii << "Protocol Error: filter options requested for non-existent\n"
|
---|
| 455 | << "filter \"" << request.filterName << "\".\n\n";
|
---|
[191] | 456 | }
|
---|
[226] | 457 |
|
---|
[186] | 458 | err = noError;
|
---|
| 459 | }
|
---|
| 460 |
|
---|
[259] | 461 | void collectserver::get_document (const DocumentRequest_t &request,
|
---|
| 462 | DocumentResponse_t &response,
|
---|
| 463 | comerror_t &err, ostream &logout) {
|
---|
[196] | 464 |
|
---|
[259] | 465 | sourcelistclass::iterator source_here = sources.begin();
|
---|
| 466 | sourcelistclass::iterator source_end = sources.end();
|
---|
| 467 | while (source_here != source_end) {
|
---|
| 468 | assert ((*source_here).s != NULL);
|
---|
| 469 | if (((*source_here).s != NULL) &&
|
---|
| 470 | ((*source_here).s->get_document (request.OID, response.doc, err, logout))) {
|
---|
| 471 | if (err != noError) return;
|
---|
| 472 | break;
|
---|
| 473 | }
|
---|
[9620] | 474 | ++source_here;
|
---|
[259] | 475 | }
|
---|
| 476 | }
|
---|
[186] | 477 |
|
---|
[4774] | 478 | void collectserver::is_searchable (bool &issearchable, comerror_t &err,
|
---|
| 479 | ostream &logout) {
|
---|
[492] | 480 |
|
---|
[4774] | 481 | sourcelistclass::iterator source_here = sources.begin();
|
---|
| 482 | sourcelistclass::iterator source_end = sources.end();
|
---|
| 483 | while (source_here != source_end) {
|
---|
| 484 | assert ((*source_here).s != NULL);
|
---|
| 485 | if (((*source_here).s != NULL) &&
|
---|
| 486 | ((*source_here).s->is_searchable (issearchable, err, logout))) {
|
---|
| 487 | if (err != noError) return;
|
---|
| 488 | break;
|
---|
| 489 | }
|
---|
[9620] | 490 | ++source_here;
|
---|
[4774] | 491 | }
|
---|
| 492 | }
|
---|
| 493 |
|
---|
| 494 |
|
---|
[492] | 495 | bool operator==(const collectserverptr &x, const collectserverptr &y) {
|
---|
| 496 | return (x.c == y.c);
|
---|
| 497 | }
|
---|
| 498 |
|
---|
| 499 | bool operator<(const collectserverptr &x, const collectserverptr &y) {
|
---|
| 500 | return (x.c < y.c);
|
---|
| 501 | }
|
---|
| 502 |
|
---|
| 503 |
|
---|
[166] | 504 | // thecollectserver remains the property of the calling code but
|
---|
| 505 | // should not be deleted until it is removed from this list.
|
---|
| 506 | void collectservermapclass::addcollectserver (collectserver *thecollectserver) {
|
---|
| 507 | // can't add a null collection server
|
---|
| 508 | assert (thecollectserver != NULL);
|
---|
| 509 | if (thecollectserver == NULL) return;
|
---|
| 510 |
|
---|
| 511 | // can't add an collection server with no collection name
|
---|
| 512 | assert (!(thecollectserver->get_collection_name()).empty());
|
---|
| 513 | if ((thecollectserver->get_collection_name()).empty()) return;
|
---|
| 514 |
|
---|
| 515 | collectserverptr cptr;
|
---|
| 516 | cptr.c = thecollectserver;
|
---|
| 517 | collectserverptrs[thecollectserver->get_collection_name()] = cptr;
|
---|
| 518 | }
|
---|
| 519 |
|
---|
| 520 | // getcollectserver will return NULL if the collectserver could not be found
|
---|
| 521 | collectserver *collectservermapclass::getcollectserver (const text_t &collection) {
|
---|
| 522 | // can't find a collection with no name
|
---|
| 523 | if (collection.empty()) return NULL;
|
---|
| 524 |
|
---|
| 525 | iterator here = collectserverptrs.find (collection);
|
---|
| 526 | if (here == collectserverptrs.end()) return NULL;
|
---|
| 527 |
|
---|
| 528 | return (*here).second.c;
|
---|
| 529 | }
|
---|