source: trunk/gsdl/src/recpt/nullproto.cpp@ 2212

Last change on this file since 2212 was 2212, checked in by sjboddie, 23 years ago

Fixed a bug that was causing the local library server to attempt to write
files to gsdlhome (i.e. the cd-rom drive if served from a cd) under certain
circumstances.

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