[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 <assert.h>
|
---|
| 28 |
|
---|
[1649] | 29 | #include "filter.h"
|
---|
| 30 | #include "browsefilter.h"
|
---|
| 31 | #include "mgqueryfilter.h"
|
---|
| 32 | #include "mgppqueryfilter.h"
|
---|
| 33 | #include "mgsearch.h"
|
---|
| 34 | #include "mgppsearch.h"
|
---|
| 35 | #include "fileutil.h"
|
---|
| 36 |
|
---|
[1892] | 37 | nullproto::nullproto() {
|
---|
| 38 | cset = NULL;
|
---|
| 39 | }
|
---|
[1649] | 40 |
|
---|
[1459] | 41 | nullproto::~nullproto() {
|
---|
| 42 | }
|
---|
| 43 |
|
---|
[1892] | 44 | // add collection to collectset (this should not be called until after the
|
---|
| 45 | // collectset has been added to the protocol with set_collectset()
|
---|
[1649] | 46 | void nullproto::add_collection (const text_t &collection, void *recpt,
|
---|
[1860] | 47 | const text_t &gsdlhome, const text_t &gdbmhome) {
|
---|
[1892] | 48 |
|
---|
| 49 | if (cset != NULL) {
|
---|
[9032] | 50 | this->cset->add_collection (collection, gsdlhome);
|
---|
[1892] | 51 | }
|
---|
| 52 | }
|
---|
[1649] | 53 |
|
---|
[1892] | 54 |
|
---|
[1679] | 55 | // remove_collection deletes the collection server of collection.
|
---|
| 56 | // This only needs to be called if a collectionserver is to be
|
---|
| 57 | // removed while the library is running. The destructor function
|
---|
| 58 | // cleans up all collectservers when the program exits.
|
---|
| 59 | void nullproto::remove_collection (const text_t &collection, ostream &logout) {
|
---|
[1860] | 60 | cset->remove_collection(collection, logout);
|
---|
[1679] | 61 | }
|
---|
| 62 |
|
---|
[166] | 63 | // this configure will configure each of the collection servers
|
---|
[2113] | 64 | void nullproto::configure (const text_t &key, const text_tarray &cfgline,
|
---|
| 65 | comerror_t &err) {
|
---|
[166] | 66 | // the naming of the collection should not be done here,
|
---|
| 67 | // it should be done just after the collection server has been
|
---|
| 68 | // created
|
---|
| 69 |
|
---|
[1860] | 70 | // the protocol should not configure the collection set; it should be
|
---|
| 71 | // done direct to the collection server set
|
---|
[2212] | 72 | if (key == "gsdlhome" || key == "gdbmhome") {
|
---|
[1860] | 73 | cset->configure(key, cfgline);
|
---|
[166] | 74 | }
|
---|
| 75 | }
|
---|
| 76 |
|
---|
| 77 | // this init will configure and init each of the collection servers
|
---|
[2113] | 78 | bool nullproto::init (comerror_t &err, ostream &logout) {
|
---|
[1860] | 79 | return cset->init(logout);
|
---|
| 80 | }
|
---|
[166] | 81 |
|
---|
[2113] | 82 | text_t nullproto::get_site_name (comerror_t &err) {
|
---|
| 83 | return "localhost";
|
---|
[166] | 84 | }
|
---|
| 85 |
|
---|
[2113] | 86 | text_t nullproto::get_protocol_name (comerror_t &err) {
|
---|
[166] | 87 | return "nullproto";
|
---|
| 88 | }
|
---|
| 89 |
|
---|
| 90 |
|
---|
| 91 | void nullproto::get_collection_list (text_tarray &collist, comerror_t &err,
|
---|
| 92 | ostream &/*logout*/) {
|
---|
[1860] | 93 | cset->getCollectionList(collist);
|
---|
| 94 | err = noError; // no error is guaranteed - collection server shouldn't
|
---|
| 95 | // about receptionist error states, logout is irrelevant
|
---|
[166] | 96 | }
|
---|
| 97 |
|
---|
| 98 | void nullproto::has_collection (const text_t &collection, bool &hascollection,
|
---|
| 99 | comerror_t &err, ostream &/*logout*/) {
|
---|
[1860] | 100 | hascollection = (cset->getCollectServer(collection) != NULL);
|
---|
[166] | 101 | err = noError;
|
---|
| 102 | }
|
---|
| 103 |
|
---|
| 104 | void nullproto::ping (const text_t &collection, bool &wassuccess,
|
---|
[2173] | 105 | comerror_t &err, ostream &logout) {
|
---|
| 106 | collectserver *cserver = cset->getCollectServer(collection);
|
---|
| 107 | if (cserver != NULL) cserver->ping(wassuccess, err, logout);
|
---|
| 108 | else err = protocolError;
|
---|
[166] | 109 | }
|
---|
| 110 |
|
---|
| 111 | void nullproto::get_collectinfo (const text_t &collection,
|
---|
| 112 | ColInfoResponse_t &collectinfo,
|
---|
[184] | 113 | comerror_t &err, ostream &logout) {
|
---|
[1860] | 114 | collectserver *cserver = cset->getCollectServer (collection);
|
---|
[184] | 115 | if (cserver != NULL) cserver->get_collectinfo (collectinfo, err, logout);
|
---|
| 116 | else err = protocolError;
|
---|
| 117 | }
|
---|
[166] | 118 |
|
---|
[184] | 119 |
|
---|
[220] | 120 | void nullproto::get_filterinfo (const text_t &collection,
|
---|
| 121 | InfoFiltersResponse_t &response,
|
---|
| 122 | comerror_t &err, ostream &logout) {
|
---|
[1860] | 123 | collectserver *cserver = cset->getCollectServer (collection);
|
---|
[220] | 124 | if (cserver != NULL) cserver->get_filterinfo (response, err, logout);
|
---|
| 125 | else err = protocolError;
|
---|
| 126 | }
|
---|
| 127 |
|
---|
[184] | 128 | void nullproto::get_filteroptions (const text_t &collection,
|
---|
[220] | 129 | const InfoFilterOptionsRequest_t &request,
|
---|
[184] | 130 | InfoFilterOptionsResponse_t &response,
|
---|
| 131 | comerror_t &err, ostream &logout) {
|
---|
[1860] | 132 | collectserver *cserver = cset->getCollectServer (collection);
|
---|
[220] | 133 | if (cserver != NULL) cserver->get_filteroptions (request, response, err, logout);
|
---|
[184] | 134 | else err = protocolError;
|
---|
[166] | 135 | }
|
---|
[184] | 136 |
|
---|
| 137 | void nullproto::filter (const text_t &collection,
|
---|
[248] | 138 | FilterRequest_t &request,
|
---|
[184] | 139 | FilterResponse_t &response,
|
---|
| 140 | comerror_t &err, ostream &logout) {
|
---|
[1860] | 141 | collectserver *cserver = cset->getCollectServer (collection);
|
---|
[184] | 142 | if (cserver != NULL) cserver->filter (request, response, err, logout);
|
---|
| 143 | else err = protocolError;
|
---|
| 144 | }
|
---|
| 145 |
|
---|
[257] | 146 | void nullproto::get_document (const text_t &collection,
|
---|
| 147 | const DocumentRequest_t &request,
|
---|
| 148 | DocumentResponse_t &response,
|
---|
| 149 | comerror_t &err, ostream &logout) {
|
---|
[1860] | 150 | collectserver *cserver = cset->getCollectServer (collection);
|
---|
[257] | 151 | if (cserver != NULL) cserver->get_document (request, response, err, logout);
|
---|
| 152 | else err = protocolError;
|
---|
| 153 | }
|
---|
[4774] | 154 |
|
---|
| 155 | void nullproto::is_searchable (const text_t &collection, bool &issearchable,
|
---|
| 156 | comerror_t &err, ostream &logout) {
|
---|
| 157 | issearchable = false;
|
---|
| 158 | collectserver *cserver = cset->getCollectServer (collection);
|
---|
| 159 | if (cserver != NULL) cserver->is_searchable (issearchable, err, logout);
|
---|
| 160 | else err = protocolError;
|
---|
| 161 | }
|
---|