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