source: trunk/gsdl/src/recpt/librarymain.cpp@ 994

Last change on this file since 994 was 994, checked in by sjboddie, 24 years ago

added error message when unable to read from collect directory - should
probably write this out to a web page too

  • Property svn:keywords set to Author Date Id Revision
File size: 8.1 KB
Line 
1/**********************************************************************
2 *
3 * librarymain.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: librarymain.cpp 994 2000-02-29 20:59:02Z sjboddie $
25 *
26 *********************************************************************/
27
28/*
29 $Log$
30 Revision 1.24 2000/02/29 20:59:02 sjboddie
31 added error message when unable to read from collect directory - should
32 probably write this out to a web page too
33
34 Revision 1.23 2000/02/21 21:59:37 sjboddie
35 gsdlhome now comes from gsdlsite.cfg
36
37 Revision 1.22 2000/02/17 02:35:48 sjboddie
38 tidied up a bit
39
40 Revision 1.21 2000/02/15 22:53:51 kjm18
41 search history stuff added.
42
43 Revision 1.20 1999/12/13 02:46:56 davidb
44 Teach buildaction about recptionist
45
46 Revision 1.19 1999/11/01 21:58:49 sjboddie
47 no longer set receptionist for some actions that used to
48
49 Revision 1.18 1999/10/25 22:29:31 sjboddie
50 receptionist now checks collect diectory for collections
51 rather than collections.txt file
52
53 Revision 1.17 1999/10/19 03:23:43 davidb
54 Collection building support through web pages
55 and internal and external link handling for collection documents
56
57 Revision 1.16 1999/10/18 20:07:33 sjboddie
58 added htmlbrowserclass
59
60 Revision 1.15 1999/10/14 23:03:10 sjboddie
61 another browser
62
63 Revision 1.14 1999/10/10 08:14:09 sjboddie
64 - metadata now returns mp rather than array
65 - redesigned browsing support (although it's not finished so
66 won't currently work ;-)
67
68 Revision 1.13 1999/09/16 21:39:35 sjboddie
69 added gb converters
70
71 Revision 1.12 1999/09/14 22:42:06 sjboddie
72 included utf8 converter
73
74 Revision 1.11 1999/09/14 22:03:27 sjboddie
75 now reads in collections from a file to avoid recompiling
76
77 Revision 1.10 1999/09/08 00:51:11 sjboddie
78 removed old interface stuff
79
80 Revision 1.9 1999/09/07 04:56:56 sjboddie
81 added GPL notice
82
83 Revision 1.8 1999/07/15 06:08:55 rjmcnab
84 Moved the adding of the actions to librarymain so that they can
85 be overriden easier.
86
87 Revision 1.7 1999/06/15 01:56:12 sjboddie
88 Got multiple collections working
89
90 Revision 1.6 1999/05/10 03:40:39 sjboddie
91 lots of changes - slowly getting document action sorted out
92
93 Revision 1.5 1999/04/19 23:56:10 rjmcnab
94 Finished the gdbm metadata stuff
95
96 Revision 1.4 1999/04/12 03:45:05 rjmcnab
97 Finished the query filter.
98
99 Revision 1.3 1999/04/06 22:20:35 rjmcnab
100 Got browsefilter working.
101
102 Revision 1.2 1999/03/05 03:53:54 sjboddie
103
104 fixed some bugs
105
106 Revision 1.1 1999/02/21 22:35:22 rjmcnab
107
108 Initial revision.
109
110 */
111
112
113#include "receptionist.h"
114#include "cgiwrapper.h"
115#include "nullproto.h"
116#include "collectserver.h"
117#include "filter.h"
118#include "browsefilter.h"
119#include "queryfilter.h"
120#include "infodbclass.h"
121#include "mgsearch.h"
122#include "mggdbmsource.h"
123#include "fileutil.h"
124#include <assert.h>
125
126#include "action.h"
127#include "statusaction.h"
128#include "pageaction.h"
129#include "pingaction.h"
130#include "queryaction.h"
131#include "documentaction.h"
132#include "authenaction.h"
133#include "usersaction.h"
134#include "authenaction.h"
135#include "extlinkaction.h"
136#include "buildaction.h"
137#include "delhistoryaction.h"
138
139#include "browserclass.h"
140#include "vlistbrowserclass.h"
141#include "hlistbrowserclass.h"
142#include "datelistbrowserclass.h"
143#include "invbrowserclass.h"
144#include "pagedbrowserclass.h"
145#include "htmlbrowserclass.h"
146
147#include "recptconfig.h"
148
149int main () {
150 receptionist recpt;
151 nullproto nproto;
152 text_tarray collections;
153
154 // get gsdlhome (if we fail the error will be picked up later -- in
155 // cgiwrapper)
156 text_t gsdlhome;
157 if (site_cfg_read (gsdlhome)) {
158 text_t collectdir = filename_cat (gsdlhome, "collect");
159 if (!read_dir (collectdir, collections)) {
160 cerr << "couldn't read collect directory - make sure gsdlhome field is correct in gsdlsite.cfg\n";
161 exit (1);
162 }
163 }
164
165 text_tarray::const_iterator thiscol = collections.begin();
166 text_tarray::const_iterator endcol = collections.end();
167
168 while (thiscol != endcol) {
169
170 // ignore the modelcol
171 if (*thiscol == "modelcol") {thiscol ++; continue;}
172
173 // this memory is created but never destroyed
174 // we're also not doing any error checking to make sure we didn't
175 // run out of memory
176 collectserver *cserver = new collectserver();
177 gdbmclass *gdbmhandler = new gdbmclass();
178 mgsearchclass *mgsearch = new mgsearchclass();
179
180 // add a null filter
181 filterclass *filter = new filterclass ();
182 cserver->add_filter (filter);
183
184 // add a browse filter
185 browsefilterclass *browsefilter = new browsefilterclass();
186 browsefilter->set_gdbmptr (gdbmhandler);
187 cserver->add_filter (browsefilter);
188
189 // add a query filter
190 queryfilterclass *queryfilter = new queryfilterclass();
191 queryfilter->set_gdbmptr (gdbmhandler);
192 queryfilter->set_mgsearchptr (mgsearch);
193 cserver->add_filter (queryfilter);
194
195 // add a mg and gdbm source
196 mggdbmsourceclass *mggdbmsource = new mggdbmsourceclass ();
197 mggdbmsource->set_gdbmptr (gdbmhandler);
198 mggdbmsource->set_mgsearchptr (mgsearch);
199 cserver->add_source (mggdbmsource);
200
201 // inform collection server and everything it contains about its
202 // collection name
203 cserver->configure ("collection", *thiscol);
204
205 nproto.add_collectserver (cserver);
206 thiscol ++;
207 }
208
209 // add the protocol to the receptionist
210 recpt.add_protocol (&nproto);
211
212 // add other converters
213 utf8inconvertclass utf8inconvert;
214 utf8outconvertclass utf8outconvert;
215 recpt.add_converter ("u", &utf8inconvert, &utf8outconvert);
216
217 if (!gsdlhome.empty()) {
218 mapinconvertclass gbinconvert;
219 gbinconvert.setmapfile (gsdlhome, "gbku", 0x25a1);
220 mapoutconvertclass gboutconvert;
221 gboutconvert.setmapfile (gsdlhome, "ugbk", 0xa1f5);
222 recpt.add_converter ("g", &gbinconvert, &gboutconvert);
223 }
224
225 // the list of actions. Note: these actions will become invalid
226 // at the end of this function.
227 statusaction astatusaction;
228 astatusaction.set_receptionist (&recpt);
229 recpt.add_action (&astatusaction);
230
231 pageaction apageaction;
232 recpt.add_action (&apageaction);
233
234 pingaction apingaction;
235 recpt.add_action (&apingaction);
236
237 queryaction aqueryaction;
238 recpt.add_action (&aqueryaction);
239
240 documentaction adocumentaction;
241 recpt.add_action (&adocumentaction);
242
243 usersaction ausersaction;
244 recpt.add_action (&ausersaction);
245
246 extlinkaction anextlinkaction;
247 recpt.add_action (&anextlinkaction);
248
249 buildaction abuildaction;
250 abuildaction.set_receptionist (&recpt);
251 recpt.add_action (&abuildaction);
252
253 authenaction aauthenaction;
254 aauthenaction.set_receptionist(&recpt);
255 recpt.add_action (&aauthenaction);
256
257 delhistoryaction adelhistoryaction;
258 recpt.add_action(&adelhistoryaction);
259
260 // list of browsers
261 vlistbrowserclass avlistbrowserclass;
262 recpt.add_browser (&avlistbrowserclass);
263 recpt.setdefaultbrowser ("VList");
264
265 hlistbrowserclass ahlistbrowserclass;
266 recpt.add_browser (&ahlistbrowserclass);
267
268 datelistbrowserclass adatelistbrowserclass;
269 recpt.add_browser (&adatelistbrowserclass);
270
271 invbrowserclass ainvbrowserclass;
272 recpt.add_browser (&ainvbrowserclass);
273
274 pagedbrowserclass apagedbrowserclass;
275 recpt.add_browser (&apagedbrowserclass);
276
277 htmlbrowserclass ahtmlbrowserclass;
278 recpt.add_browser (&ahtmlbrowserclass);
279
280 cgiwrapper (recpt, "");
281 return 0;
282}
283
284
285
286
287
Note: See TracBrowser for help on using the repository browser.