[166] | 1 | /**********************************************************************
|
---|
| 2 | *
|
---|
| 3 | * recptproto.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 "recptproto.h"
|
---|
| 27 | #include <assert.h>
|
---|
| 28 |
|
---|
| 29 |
|
---|
[1649] | 30 | // add collection server to protocol
|
---|
| 31 | void recptproto::add_collection (const text_t &/*collection*/, void * /*recpt*/,
|
---|
| 32 | const text_t &/*gsdlhome*/, const text_t &/*gdbmhome*/) {
|
---|
| 33 | }
|
---|
| 34 |
|
---|
[1679] | 35 | void recptproto::remove_collection (const text_t &/*collection*/, ostream &/*logout*/) {
|
---|
| 36 | }
|
---|
| 37 |
|
---|
[166] | 38 | // configure should be called for each line in the configuration file
|
---|
[2113] | 39 | void recptproto::configure (const text_t &/*key*/, const text_tarray &/*cfgline*/, comerror_t &) {
|
---|
[166] | 40 | }
|
---|
| 41 |
|
---|
| 42 | // init should be called after the configuration but before any other
|
---|
| 43 | // functions are called. If init returns false a message will be written
|
---|
| 44 | // out to the log file and no other output should be produced.
|
---|
[2113] | 45 | bool recptproto::init (comerror_t &err, ostream &/*logout*/) {
|
---|
[166] | 46 | return true;
|
---|
| 47 | }
|
---|
| 48 |
|
---|
[1860] | 49 | // get site name should return the name of the site used.
|
---|
| 50 | // This is trivially empty in the case of a null protocol. If a remote
|
---|
| 51 | // connection to a site is being used then this should return the name
|
---|
| 52 | // used to label a site
|
---|
[2113] | 53 | text_t recptproto::get_site_name(comerror_t &err) {
|
---|
| 54 | return "localhost";
|
---|
[1860] | 55 | }
|
---|
| 56 |
|
---|
[166] | 57 | // get_protocol_name should return the name of this protocol (e.g. recptproto)
|
---|
| 58 | // that can be used to do run time type identification and display information
|
---|
| 59 | // about the protocol.
|
---|
[2113] | 60 | text_t recptproto::get_protocol_name (comerror_t &err) {
|
---|
[166] | 61 | return "recptproto";
|
---|
| 62 | }
|
---|
| 63 |
|
---|
| 64 | // get_collection_list returns the list of collections that
|
---|
| 65 | // this protocol knows about
|
---|
| 66 | void recptproto::get_collection_list (text_tarray &collist, comerror_t &err,
|
---|
| 67 | ostream &/*logout*/) {
|
---|
[172] | 68 | collist.erase(collist.begin(),collist.end());
|
---|
[166] | 69 | err = noError;
|
---|
| 70 | }
|
---|
| 71 |
|
---|
| 72 | // has_collection sets 'hascollection' to be true if the protocol
|
---|
| 73 | // can communicate with the collection (i.e. it is within its
|
---|
| 74 | // collection list). This function should be implemented in as
|
---|
| 75 | // efficient time as possible as it will be called for each page
|
---|
| 76 | // access and for each protocol.
|
---|
| 77 | void recptproto::has_collection (const text_t &/*collection*/, bool &hascollection,
|
---|
| 78 | comerror_t &err, ostream &/*logout*/) {
|
---|
| 79 | hascollection = false;
|
---|
| 80 | err = noError;
|
---|
| 81 | }
|
---|
| 82 |
|
---|
| 83 | // sets 'wassuccess' to be true if a successful ping was done to
|
---|
| 84 | // the given collection.
|
---|
| 85 | void recptproto::ping (const text_t &/*collection*/, bool &wassuccess,
|
---|
| 86 | comerror_t &err, ostream &/*logout*/) {
|
---|
| 87 | wassuccess = false; // no collections are supported by this class
|
---|
| 88 | err = noError;
|
---|
| 89 | }
|
---|
| 90 |
|
---|
| 91 | // obtains general information about the collection
|
---|
| 92 | void recptproto::get_collectinfo (const text_t &/*collection*/,
|
---|
| 93 | ColInfoResponse_t &/*collectinfo*/,
|
---|
| 94 | comerror_t &err, ostream &/*logout*/) {
|
---|
| 95 | err = protocolError;
|
---|
| 96 | }
|
---|
| 97 |
|
---|
[220] | 98 | // gets a list of all the filters
|
---|
| 99 | void recptproto::get_filterinfo (const text_t &/*collection*/,
|
---|
| 100 | InfoFiltersResponse_t &/*reponse*/,
|
---|
| 101 | comerror_t &err, ostream &/*logout*/) {
|
---|
| 102 | err = protocolError;
|
---|
| 103 | }
|
---|
| 104 |
|
---|
| 105 | // gets all the filter options for a particular filter
|
---|
[184] | 106 | void recptproto::get_filteroptions (const text_t &/*collection*/,
|
---|
[220] | 107 | const InfoFilterOptionsRequest_t &/*request*/,
|
---|
[184] | 108 | InfoFilterOptionsResponse_t &/*response*/,
|
---|
| 109 | comerror_t &err, ostream &/*logout*/) {
|
---|
| 110 | err = protocolError;
|
---|
| 111 | }
|
---|
[166] | 112 |
|
---|
[184] | 113 | // filters (search or browse) a result set
|
---|
| 114 | void recptproto::filter (const text_t &/*collection*/,
|
---|
[248] | 115 | FilterRequest_t &/*request*/,
|
---|
[184] | 116 | FilterResponse_t &/*response*/,
|
---|
| 117 | comerror_t &err, ostream &/*logout*/) {
|
---|
| 118 | err = protocolError;
|
---|
| 119 | }
|
---|
[166] | 120 |
|
---|
[257] | 121 | void recptproto::get_document (const text_t &/*collection*/,
|
---|
| 122 | const DocumentRequest_t &/*request*/,
|
---|
| 123 | DocumentResponse_t &/*response*/,
|
---|
| 124 | comerror_t &err, ostream &/*logout*/) {
|
---|
| 125 | err = protocolError;
|
---|
| 126 | }
|
---|
[184] | 127 |
|
---|
[4774] | 128 | // sets issearchable to true if the given colection is searchable
|
---|
| 129 | void recptproto::is_searchable (const text_t &/*collection*/, bool &issearchable,
|
---|
| 130 | comerror_t &err, ostream &/*logout*/) {
|
---|
| 131 | issearchable = false; // no collections are supported by this class
|
---|
| 132 | err = noError;
|
---|
| 133 | }
|
---|
[184] | 134 |
|
---|
| 135 |
|
---|
| 136 |
|
---|
| 137 |
|
---|
[257] | 138 |
|
---|
| 139 |
|
---|
[4774] | 140 |
|
---|
[166] | 141 | // therecptproto remains the property of the calling code but
|
---|
| 142 | // should not be deleted until it is removed from this list.
|
---|
| 143 | void recptprotolistclass::addrecptproto (recptproto *therecptproto) {
|
---|
| 144 | // can't add a protocol that doesn't exist
|
---|
| 145 | assert (therecptproto != NULL);
|
---|
| 146 | if (therecptproto == NULL) return;
|
---|
| 147 |
|
---|
| 148 | recptprotoptr rpp;
|
---|
| 149 | rpp.p = therecptproto;
|
---|
| 150 |
|
---|
| 151 | recptprotoptrs.push_back(rpp);
|
---|
| 152 | }
|
---|
| 153 |
|
---|
| 154 | // getrecptproto will return NULL if a recptproto for the given colelction
|
---|
| 155 | // could not be found
|
---|
| 156 | recptproto *recptprotolistclass::getrecptproto (const text_t &collection,
|
---|
| 157 | ostream &logout) {
|
---|
| 158 | iterator here = recptprotoptrs.begin ();
|
---|
| 159 | iterator end = recptprotoptrs.end ();
|
---|
| 160 | bool hascollection;
|
---|
| 161 | comerror_t err;
|
---|
| 162 |
|
---|
| 163 | while (here != end) {
|
---|
| 164 | assert ((*here).p != NULL);
|
---|
| 165 | if ((*here).p != NULL) {
|
---|
| 166 | (*here).p->has_collection (collection, hascollection, err, logout);
|
---|
| 167 | if ((err == noError) && (hascollection == true)) return (*here).p;
|
---|
| 168 | }
|
---|
| 169 |
|
---|
| 170 | here++;
|
---|
| 171 | }
|
---|
| 172 |
|
---|
| 173 | return NULL;
|
---|
| 174 | }
|
---|