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 | * $Id: nullproto.cpp 801 1999-12-05 21:23:39Z sjboddie $
|
---|
25 | *
|
---|
26 | *********************************************************************/
|
---|
27 |
|
---|
28 | /*
|
---|
29 | $Log$
|
---|
30 | Revision 1.12 1999/12/05 21:23:39 sjboddie
|
---|
31 | support for multiple gsdlhomes and gdbmhomes
|
---|
32 |
|
---|
33 | Revision 1.11 1999/10/25 22:29:32 sjboddie
|
---|
34 | receptionist now checks collect diectory for collections
|
---|
35 | rather than collections.txt file
|
---|
36 |
|
---|
37 | Revision 1.10 1999/10/19 03:23:43 davidb
|
---|
38 | Collection building support through web pages
|
---|
39 | and internal and external link handling for collection documents
|
---|
40 |
|
---|
41 | Revision 1.9 1999/09/07 04:56:56 sjboddie
|
---|
42 | added GPL notice
|
---|
43 |
|
---|
44 | Revision 1.8 1999/06/27 22:04:47 sjboddie
|
---|
45 | now read in build.cfg before collect.cfg so that the indexmaps
|
---|
46 | are available if required to decode defaultindex, defaultsubcollection,
|
---|
47 | and defaultlanguage
|
---|
48 |
|
---|
49 | Revision 1.7 1999/06/15 02:16:45 sjboddie
|
---|
50 | small change to prevent collectdir configuration string from being passed
|
---|
51 | to everything
|
---|
52 |
|
---|
53 | Revision 1.6 1999/05/10 03:40:41 sjboddie
|
---|
54 | lots of changes - slowly getting document action sorted out
|
---|
55 |
|
---|
56 | Revision 1.5 1999/04/30 01:59:41 sjboddie
|
---|
57 | lots of stuff - getting documentaction working (documentaction replaces
|
---|
58 | old browseaction)
|
---|
59 |
|
---|
60 | Revision 1.4 1999/03/31 23:44:48 rjmcnab
|
---|
61 | Altered the protocol so that the metadata is part of the filter.
|
---|
62 |
|
---|
63 | Revision 1.3 1999/03/03 23:26:35 sjboddie
|
---|
64 |
|
---|
65 | Implemented more of the protocol
|
---|
66 |
|
---|
67 | Revision 1.2 1999/02/25 21:58:58 rjmcnab
|
---|
68 |
|
---|
69 | Merged sources.
|
---|
70 |
|
---|
71 | Revision 1.1 1999/02/21 22:35:22 rjmcnab
|
---|
72 |
|
---|
73 | Initial revision.
|
---|
74 |
|
---|
75 | */
|
---|
76 |
|
---|
77 |
|
---|
78 | #include "nullproto.h"
|
---|
79 | #include "colservrconfig.h"
|
---|
80 | #include <assert.h>
|
---|
81 |
|
---|
82 |
|
---|
83 | // this configure will configure each of the collection servers
|
---|
84 | void nullproto::configure (const text_t &key, const text_tarray &cfgline) {
|
---|
85 | // the naming of the collection should not be done here,
|
---|
86 | // it should be done just after the collection server has been
|
---|
87 | // created
|
---|
88 | if (key == "collection" || key == "collectdir") return;
|
---|
89 |
|
---|
90 | collectservermapclass::iterator here = cservers.begin();
|
---|
91 | collectservermapclass::iterator end = cservers.end();
|
---|
92 |
|
---|
93 | while (here != end) {
|
---|
94 | assert ((*here).second.c != NULL);
|
---|
95 | if ((*here).second.c != NULL) {
|
---|
96 | if (key == "collectinfo") {
|
---|
97 | if ((*here).first == cfgline[0]) {
|
---|
98 | (*here).second.c->configure ("gsdlhome", cfgline[1]);
|
---|
99 | (*here).second.c->configure ("gdbmhome", cfgline[2]);
|
---|
100 | }
|
---|
101 | } else {
|
---|
102 | (*here).second.c->configure (key, cfgline);
|
---|
103 | }
|
---|
104 | }
|
---|
105 |
|
---|
106 | here++;
|
---|
107 | }
|
---|
108 | }
|
---|
109 |
|
---|
110 | // this init will configure and init each of the collection servers
|
---|
111 | bool nullproto::init (ostream &logout) {
|
---|
112 | collectservermapclass::iterator here = cservers.begin();
|
---|
113 | collectservermapclass::iterator end = cservers.end();
|
---|
114 |
|
---|
115 | while (here != end) {
|
---|
116 | assert ((*here).second.c != NULL);
|
---|
117 | if ((*here).second.c != NULL) {
|
---|
118 | const colservrconf &configinfo = (*here).second.c->get_configinfo ();
|
---|
119 |
|
---|
120 | // configure this collection server
|
---|
121 |
|
---|
122 | // note that we read build.cfg before collect.cfg so that the indexmaps
|
---|
123 | // are available to decode defaultindex, defaultsubcollection, and
|
---|
124 | // defaultlanguage
|
---|
125 | if (!build_cfg_read (*((*here).second.c), configinfo.gsdlhome,
|
---|
126 | configinfo.collection)) {
|
---|
127 | outconvertclass text_t2ascii;
|
---|
128 | logout << text_t2ascii
|
---|
129 | << "Warning: couldn't read build.cfg file for collection \"" //****
|
---|
130 | << configinfo.collection << "\", gsdlhome=\""
|
---|
131 | << configinfo.gsdlhome << "\"\n";
|
---|
132 | // return false; //****
|
---|
133 | here ++;
|
---|
134 | continue;
|
---|
135 | }
|
---|
136 |
|
---|
137 | if (!collect_cfg_read (*((*here).second.c), configinfo.gsdlhome,
|
---|
138 | configinfo.collection)) {
|
---|
139 | outconvertclass text_t2ascii;
|
---|
140 | logout << text_t2ascii
|
---|
141 | << "Warning: couldn't read collect.cfg file for collection \""
|
---|
142 | << configinfo.collection << "\", gsdlhome=\""
|
---|
143 | << configinfo.gsdlhome << "\"\n";
|
---|
144 | // return false; //****
|
---|
145 | here ++;
|
---|
146 | continue;
|
---|
147 | }
|
---|
148 |
|
---|
149 | if (!(*here).second.c->init (logout)) return false;
|
---|
150 | }
|
---|
151 | here++;
|
---|
152 | }
|
---|
153 |
|
---|
154 | return true;
|
---|
155 | }
|
---|
156 |
|
---|
157 | text_t nullproto::get_protocol_name () {
|
---|
158 | return "nullproto";
|
---|
159 | }
|
---|
160 |
|
---|
161 |
|
---|
162 | void nullproto::get_collection_list (text_tarray &collist, comerror_t &err,
|
---|
163 | ostream &/*logout*/) {
|
---|
164 | collist.erase(collist.begin(),collist.end());
|
---|
165 | err = noError;
|
---|
166 |
|
---|
167 | collectservermapclass::iterator here = cservers.begin();
|
---|
168 | collectservermapclass::iterator end = cservers.end();
|
---|
169 | while (here != end) {
|
---|
170 | assert ((*here).second.c != NULL);
|
---|
171 | if ((*here).second.c != NULL) {
|
---|
172 | collist.push_back ((*here).second.c->get_collection_name());
|
---|
173 | }
|
---|
174 | here++;
|
---|
175 | }
|
---|
176 | }
|
---|
177 |
|
---|
178 | void nullproto::has_collection (const text_t &collection, bool &hascollection,
|
---|
179 | comerror_t &err, ostream &/*logout*/) {
|
---|
180 | hascollection = (cservers.getcollectserver(collection) != NULL);
|
---|
181 | err = noError;
|
---|
182 | }
|
---|
183 |
|
---|
184 | void nullproto::ping (const text_t &collection, bool &wassuccess,
|
---|
185 | comerror_t &err, ostream &/*logout*/) {
|
---|
186 | wassuccess = (cservers.getcollectserver(collection) != NULL);
|
---|
187 | err = noError;
|
---|
188 | }
|
---|
189 |
|
---|
190 | void nullproto::get_collectinfo (const text_t &collection,
|
---|
191 | ColInfoResponse_t &collectinfo,
|
---|
192 | comerror_t &err, ostream &logout) {
|
---|
193 | collectserver *cserver = cservers.getcollectserver (collection);
|
---|
194 | if (cserver != NULL) cserver->get_collectinfo (collectinfo, err, logout);
|
---|
195 | else err = protocolError;
|
---|
196 | }
|
---|
197 |
|
---|
198 |
|
---|
199 | void nullproto::get_filterinfo (const text_t &collection,
|
---|
200 | InfoFiltersResponse_t &response,
|
---|
201 | comerror_t &err, ostream &logout) {
|
---|
202 | collectserver *cserver = cservers.getcollectserver (collection);
|
---|
203 | if (cserver != NULL) cserver->get_filterinfo (response, err, logout);
|
---|
204 | else err = protocolError;
|
---|
205 | }
|
---|
206 |
|
---|
207 | void nullproto::get_filteroptions (const text_t &collection,
|
---|
208 | const InfoFilterOptionsRequest_t &request,
|
---|
209 | InfoFilterOptionsResponse_t &response,
|
---|
210 | comerror_t &err, ostream &logout) {
|
---|
211 | collectserver *cserver = cservers.getcollectserver (collection);
|
---|
212 | if (cserver != NULL) cserver->get_filteroptions (request, response, err, logout);
|
---|
213 | else err = protocolError;
|
---|
214 | }
|
---|
215 |
|
---|
216 | void nullproto::filter (const text_t &collection,
|
---|
217 | FilterRequest_t &request,
|
---|
218 | FilterResponse_t &response,
|
---|
219 | comerror_t &err, ostream &logout) {
|
---|
220 | collectserver *cserver = cservers.getcollectserver (collection);
|
---|
221 | if (cserver != NULL) cserver->filter (request, response, err, logout);
|
---|
222 | else err = protocolError;
|
---|
223 | }
|
---|
224 |
|
---|
225 | void nullproto::get_document (const text_t &collection,
|
---|
226 | const DocumentRequest_t &request,
|
---|
227 | DocumentResponse_t &response,
|
---|
228 | comerror_t &err, ostream &logout) {
|
---|
229 | collectserver *cserver = cservers.getcollectserver (collection);
|
---|
230 | if (cserver != NULL) cserver->get_document (request, response, err, logout);
|
---|
231 | else err = protocolError;
|
---|
232 | }
|
---|