source: gsdl/trunk/src/protocol/nullproto.cpp@ 16310

Last change on this file since 16310 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.7 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 "mgsearch.h"
34#include "mgppsearch.h"
35#include "fileutil.h"
36
37nullproto::nullproto() {
38 cset = NULL;
39}
40
41nullproto::~nullproto() {
42}
43
44// add collection to collectset (this should not be called until after the
45// collectset has been added to the protocol with set_collectset()
46void nullproto::add_collection (const text_t &collection, void *recpt,
47 const text_t &gsdlhome, const text_t& collecthome,
48 const text_t &dbhome)
49{
50
51 if (cset != NULL) {
52 this->cset->add_collection (collection, gsdlhome, collecthome);
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 || key == "collecthome" || key == "collectdir") {
76 cset->configure(key, cfgline);
77 }
78}
79
80// this init will configure and init each of the collection servers
81bool nullproto::init (comerror_t &err, ostream &logout) {
82 return cset->init(logout);
83}
84
85text_t nullproto::get_site_name (comerror_t &err) {
86 return "localhost";
87}
88
89text_t nullproto::get_protocol_name (comerror_t &err) {
90 return "nullproto";
91}
92
93
94void nullproto::get_collection_list (text_tarray &collist, comerror_t &err,
95 ostream &/*logout*/) {
96 cset->getCollectionList(collist);
97 err = noError; // no error is guaranteed - collection server shouldn't
98 // about receptionist error states, logout is irrelevant
99}
100
101void nullproto::has_collection (const text_t &collection, bool &hascollection,
102 comerror_t &err, ostream &/*logout*/) {
103 hascollection = (cset->getCollectServer(collection) != NULL);
104 err = noError;
105}
106
107void nullproto::ping (const text_t &collection, bool &wassuccess,
108 comerror_t &err, ostream &logout) {
109 collectserver *cserver = cset->getCollectServer(collection);
110 if (cserver != NULL) cserver->ping(wassuccess, err, logout);
111 else err = protocolError;
112}
113
114void nullproto::get_collectinfo (const text_t &collection,
115 ColInfoResponse_t &collectinfo,
116 comerror_t &err, ostream &logout) {
117 collectserver *cserver = cset->getCollectServer (collection);
118 if (cserver != NULL) cserver->get_collectinfo (collectinfo, err, logout);
119 else err = protocolError;
120}
121
122
123void nullproto::get_filterinfo (const text_t &collection,
124 InfoFiltersResponse_t &response,
125 comerror_t &err, ostream &logout) {
126 collectserver *cserver = cset->getCollectServer (collection);
127 if (cserver != NULL) cserver->get_filterinfo (response, err, logout);
128 else err = protocolError;
129}
130
131void nullproto::get_filteroptions (const text_t &collection,
132 const InfoFilterOptionsRequest_t &request,
133 InfoFilterOptionsResponse_t &response,
134 comerror_t &err, ostream &logout) {
135 collectserver *cserver = cset->getCollectServer (collection);
136 if (cserver != NULL) cserver->get_filteroptions (request, response, err, logout);
137 else err = protocolError;
138}
139
140void nullproto::filter (const text_t &collection,
141 FilterRequest_t &request,
142 FilterResponse_t &response,
143 comerror_t &err, ostream &logout) {
144 collectserver *cserver = cset->getCollectServer (collection);
145 if (cserver != NULL) cserver->filter (request, response, err, logout);
146 else err = protocolError;
147}
148
149void nullproto::get_document (const text_t &collection,
150 const DocumentRequest_t &request,
151 DocumentResponse_t &response,
152 comerror_t &err, ostream &logout) {
153 collectserver *cserver = cset->getCollectServer (collection);
154 if (cserver != NULL) cserver->get_document (request, response, err, logout);
155 else err = protocolError;
156}
157
158void nullproto::is_searchable (const text_t &collection, bool &issearchable,
159 comerror_t &err, ostream &logout) {
160 issearchable = false;
161 collectserver *cserver = cset->getCollectServer (collection);
162 if (cserver != NULL) cserver->is_searchable (issearchable, err, logout);
163 else err = protocolError;
164}
Note: See TracBrowser for help on using the repository browser.