source: branches/z3950-branch/gsdl/src/recpt/nullproto.cpp@ 1342

Last change on this file since 1342 was 1342, checked in by johnmcp, 24 years ago

Relatively stable z39.50 implementation now, merged with the mgpp source.
(Still needs a decent interface and query language though...)

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 6.1 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 "colservrconfig.h"
28#include <assert.h>
29
30
31// this configure will configure each of the collection servers
32void nullproto::configure (const text_t &key, const text_tarray &cfgline) {
33 // the naming of the collection should not be done here,
34 // it should be done just after the collection server has been
35 // created
36 if (key == "collection" || key == "collectdir") return;
37
38 collectservermapclass::iterator here = cservers.begin();
39 collectservermapclass::iterator end = cservers.end();
40
41 while (here != end) {
42 assert ((*here).second.c != NULL);
43 if ((*here).second.c != NULL) {
44 if (key == "collectinfo") {
45 if ((*here).first == cfgline[0]) {
46 (*here).second.c->configure ("gsdlhome", cfgline[1]);
47 (*here).second.c->configure ("gdbmhome", cfgline[2]);
48 }
49 } else {
50 (*here).second.c->configure (key, cfgline);
51 }
52 }
53
54 here++;
55 }
56}
57
58// this init will configure and init each of the collection servers
59bool nullproto::init (ostream &logout) {
60 collectservermapclass::iterator here = cservers.begin();
61 collectservermapclass::iterator end = cservers.end();
62
63 while (here != end) {
64 assert ((*here).second.c != NULL);
65 if ((*here).second.c != NULL) {
66 const colservrconf &configinfo = (*here).second.c->get_configinfo ();
67 bool failed = false;
68
69 // configure this collection server
70
71 // note that we read build.cfg before collect.cfg so that the indexmaps
72 // are available to decode defaultindex, defaultsubcollection, and
73 // defaultlanguage
74 if (!build_cfg_read (*((*here).second.c), configinfo.gsdlhome,
75 configinfo.collection)) {
76 outconvertclass text_t2ascii;
77 logout << text_t2ascii
78 << "Warning: couldn't read build.cfg file for collection \"" //****
79 << configinfo.collection << "\", gsdlhome=\""
80 << configinfo.gsdlhome << "\"\n";
81 failed = true;
82 }
83
84 if (!collect_cfg_read (*((*here).second.c), configinfo.gsdlhome,
85 configinfo.collection)) {
86 outconvertclass text_t2ascii;
87 logout << text_t2ascii
88 << "Warning: couldn't read collect.cfg file for collection \""
89 << configinfo.collection << "\", gsdlhome=\""
90 << configinfo.gsdlhome << "\"\n";
91 failed = true;
92 }
93
94 // don't bother initializing if one of the config files
95 // wasn't read correctly
96 if (!failed) {
97 if (!(*here).second.c->init (logout)) return false;
98 }
99 }
100 here++;
101 }
102
103 return true;
104}
105
106text_t nullproto::get_protocol_name () {
107 return "nullproto";
108}
109
110
111void nullproto::get_collection_list (text_tarray &collist, comerror_t &err,
112 ostream &/*logout*/) {
113 collist.erase(collist.begin(),collist.end());
114 err = noError;
115
116 collectservermapclass::iterator here = cservers.begin();
117 collectservermapclass::iterator end = cservers.end();
118 while (here != end) {
119 assert ((*here).second.c != NULL);
120 if ((*here).second.c != NULL) {
121 collist.push_back ((*here).second.c->get_collection_name());
122 }
123 here++;
124 }
125}
126
127void nullproto::has_collection (const text_t &collection, bool &hascollection,
128 comerror_t &err, ostream &/*logout*/) {
129 hascollection = (cservers.getcollectserver(collection) != NULL);
130 err = noError;
131}
132
133void nullproto::ping (const text_t &collection, bool &wassuccess,
134 comerror_t &err, ostream &/*logout*/) {
135 wassuccess = (cservers.getcollectserver(collection) != NULL);
136 err = noError;
137}
138
139void nullproto::get_collectinfo (const text_t &collection,
140 ColInfoResponse_t &collectinfo,
141 comerror_t &err, ostream &logout) {
142 collectserver *cserver = cservers.getcollectserver (collection);
143 if (cserver != NULL) cserver->get_collectinfo (collectinfo, err, logout);
144 else err = protocolError;
145}
146
147
148void nullproto::get_filterinfo (const text_t &collection,
149 InfoFiltersResponse_t &response,
150 comerror_t &err, ostream &logout) {
151 collectserver *cserver = cservers.getcollectserver (collection);
152 if (cserver != NULL) cserver->get_filterinfo (response, err, logout);
153 else err = protocolError;
154}
155
156void nullproto::get_filteroptions (const text_t &collection,
157 const InfoFilterOptionsRequest_t &request,
158 InfoFilterOptionsResponse_t &response,
159 comerror_t &err, ostream &logout) {
160 collectserver *cserver = cservers.getcollectserver (collection);
161 if (cserver != NULL) cserver->get_filteroptions (request, response, err, logout);
162 else err = protocolError;
163}
164
165void nullproto::filter (const text_t &collection,
166 FilterRequest_t &request,
167 FilterResponse_t &response,
168 comerror_t &err, ostream &logout) {
169 collectserver *cserver = cservers.getcollectserver (collection);
170 if (cserver != NULL) cserver->filter (request, response, err, logout);
171 else err = protocolError;
172}
173
174void nullproto::get_document (const text_t &collection,
175 const DocumentRequest_t &request,
176 DocumentResponse_t &response,
177 comerror_t &err, ostream &logout) {
178 collectserver *cserver = cservers.getcollectserver (collection);
179 if (cserver != NULL) cserver->get_document (request, response, err, logout);
180 else err = protocolError;
181}
Note: See TracBrowser for help on using the repository browser.