source: gsdl/trunk/runtime-src/src/protocol/nullproto.cpp@ 20821

Last change on this file since 20821 was 20821, checked in by mdewsnip, 12 years ago

Removed unnecessary inclusion of MG and MGPP headers.

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