source: main/trunk/greenstone2/runtime-src/src/protocol/recptproto.cpp@ 24874

Last change on this file since 24874 was 16310, checked in by davidb, 16 years ago

Introduction of 'collecthome' which parallels 'gsdlhome' to allow the toplevel collect folder to be outside of the gsdlhome area

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