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