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

Last change on this file since 15433 was 15433, checked in by mdewsnip, 16 years ago

(Adding new DB support) Removed unnecessary inclusions of "infodbclass.h".

  • Property svn:keywords set to Author Date Id Revision
File size: 8.7 KB
Line 
1/**********************************************************************
2 *
3 * librarymain.cpp --
4 * Copyright (C) 1999 The New Zaland 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 "gsdl_modules_cfg.h"
27#include "receptionist.h"
28#include "cgiwrapper.h"
29#include "fileutil.h"
30#include "nullproto.h"
31// z39.50 stuff - johnmcp
32#if defined(USE_Z3950)
33#include "z3950proto.h"
34#endif
35#include "collectserver.h"
36#include "filter.h"
37#include "browsefilter.h"
38#include "collectset.h"
39#include <assert.h>
40
41#include "action.h"
42#include "statusaction.h"
43#include "pageaction.h"
44#include "pingaction.h"
45#include "queryaction.h"
46#include "documentaction.h"
47#include "authenaction.h"
48#include "usersaction.h"
49#include "extlinkaction.h"
50
51#ifdef GSDL_USE_EXPORT_ACTION
52#include "exportaction.h"
53#endif
54
55#ifdef GSDL_USE_CL_DISPLAY_ACTION
56#include "cldisplayaction.h"
57#endif
58
59#ifdef GSDL_USE_COURSES_ACTION
60#include "coursesaction.h"
61#endif
62
63#ifdef GSDL_USE_COMPOSITION_ACTION
64#include "compositionaction.h"
65#endif
66
67#ifdef GSDL_USE_INDEX_BROWSE_ACTION
68#include "indexbrowseaction.h"
69#endif
70
71#ifdef GSDL_USE_DIR_BROWSE_ACTION
72#include "dirbrowseaction.h"
73#endif
74
75#ifdef GSDL_USE_GENERATOR_ACTION
76#include "generatoraction.h"
77#endif
78
79#ifdef GSDL_USE_GTI_ACTION
80#include "gtiaction.h"
81#endif
82
83#include "tipaction.h"
84#include "collectoraction.h"
85#include "depositoraction.h"
86#include "browseaction.h"
87#include "phindaction.h"
88
89#include "browserclass.h"
90#include "vlistbrowserclass.h"
91#include "hlistbrowserclass.h"
92#include "datelistbrowserclass.h"
93#include "invbrowserclass.h"
94#include "pagedbrowserclass.h"
95#include "htmlbrowserclass.h"
96#include "phindbrowserclass.h"
97
98#ifdef GSDL_USE_CLASSIFIER_BROWSER
99//classifier browsers
100
101#include "treeclassifierbrowserclass.h"
102#ifdef GSDL_USE_TREE_EX_CLASSIFIER_BROWSER
103#include "treeexclassifierbrowserclass.h"
104#endif
105
106#endif //GSDL_USE_CLASSIFIER_BROWSER
107
108int main () {
109 receptionist recpt;
110 nullproto nproto;
111 collectset *cservers;
112#if defined(USE_Z3950)
113 z3950proto zproto;
114#endif
115 text_t gsdlhome;
116
117 cservers = new collectset(gsdlhome);
118
119 // configure the receptionist server list
120 text_tarray collection_list;
121 cservers->getCollectionList(collection_list);
122 text_tarray::iterator collection_iterator = collection_list.begin();
123 while (collection_iterator != collection_list.end())
124 {
125 text_tarray colinfo;
126 colinfo.push_back(*collection_iterator);
127 colinfo.push_back(gsdlhome);
128 colinfo.push_back(gsdlhome);
129 recpt.configure("collectinfo", colinfo);
130 collection_iterator++;
131 }
132
133 // set up the null protocol
134 nproto.set_collectset(cservers);
135
136 // add the protocol to the receptionist
137 recpt.add_protocol (&nproto);
138
139 // z39.50 stuff - johnmcp
140#if defined(USE_Z3950)
141 // add the z39.50 server information. Read in the file
142 // etc/recpt/z3950.cfg for list of servers and their databases.
143 text_t z3950cfg = filename_cat (gsdlhome, "etc");
144 z3950cfg = filename_cat (z3950cfg, "packages");
145 z3950cfg = filename_cat (z3950cfg, "z3950.cfg");
146#ifdef USE_FASTCGI
147 // currently can't use z39.50 if fastcgi used
148#warning "Disabling z39.50 support as fastcgi is in use"
149 if (0) {
150#else
151 if (file_exists(z3950cfg)) {
152#endif
153 text_t z3950err = filename_cat (gsdlhome, "etc", "z3950log.txt");
154 zproto.read_config_file(z3950cfg,z3950err);
155 // only add this protocol if we have any servers configured.
156 if (zproto.getServerCount()>0)
157 recpt.add_protocol (&zproto);
158 }
159#endif
160
161#ifdef GSDL_USE_TIP_ACTION
162 // the list of actions. Note: these actions will become invalid
163 // at the end of this function. We will clean them.
164 recpt.add_action (new tipaction());
165#endif
166
167#ifdef GSDL_USE_STATUS_ACTION
168 statusaction *astatusaction = new statusaction();
169 astatusaction->set_receptionist (&recpt);
170 recpt.add_action (astatusaction);
171#endif
172
173 pageaction *apageaction = new pageaction();
174 apageaction->set_receptionist (&recpt);
175 recpt.add_action (apageaction);
176
177#ifdef GSDL_USE_PING_ACTION
178 recpt.add_action (new pingaction());
179#endif
180
181 queryaction *aqueryaction = new queryaction();
182 aqueryaction->set_receptionist (&recpt);
183 recpt.add_action (aqueryaction);
184
185 documentaction *adocumentaction = new documentaction();
186 adocumentaction->set_receptionist (&recpt);
187 recpt.add_action (adocumentaction);
188
189 text_t userdbfile = filename_cat(gsdlhome, "etc", "users.db");
190 userdbclass *udb = new userdbclass(userdbfile);
191
192 text_t keydbfile = filename_cat(gsdlhome, "etc", "key.db");
193 keydbclass *kdb = new keydbclass(keydbfile);
194
195#ifdef GSDL_USE_USERS_ACTION
196 usersaction *ausersaction = new usersaction();
197 ausersaction->set_userdb(udb);
198 recpt.add_action (ausersaction);
199#endif
200
201#ifdef GSDL_USE_EXTLINK_ACTION
202 extlinkaction *aextlinkaction = new extlinkaction();
203 aextlinkaction->set_receptionist(&recpt);
204 recpt.add_action (aextlinkaction);
205#endif
206
207#ifdef GSDL_USE_AUTHEN_ACTION
208 authenaction *aauthenaction = new authenaction();
209 aauthenaction->set_userdb(udb);
210 aauthenaction->set_keydb(kdb);
211 aauthenaction->set_receptionist(&recpt);
212 recpt.add_action (aauthenaction);
213#endif
214
215#ifdef GSDL_USE_COLLECTOR_ACTION
216 collectoraction *acollectoraction = new collectoraction();
217 acollectoraction->set_receptionist (&recpt);
218 recpt.add_action(acollectoraction);
219#endif
220
221#ifdef GSDL_USE_DEPOSITOR_ACTION
222 depositoraction *adepositoraction = new depositoraction();
223 adepositoraction->set_receptionist (&recpt);
224 recpt.add_action(adepositoraction);
225#endif
226
227#ifdef GSDL_USE_BROWSE_ACTION
228 browseaction *abrowseaction = new browseaction();
229 abrowseaction->set_receptionist (&recpt);
230 recpt.add_action(abrowseaction);
231#endif
232
233#ifdef GSDL_USE_PHIND_ACTION
234 recpt.add_action(new phindaction());
235#endif
236
237#ifdef GSDL_USE_GTI_ACTION
238 gtiaction *agtiaction = new gtiaction();
239 agtiaction->set_receptionist(&recpt);
240 recpt.add_action(agtiaction);
241#endif
242
243 // list of browsers
244 vlistbrowserclass avlistbrowserclass;
245 avlistbrowserclass.set_receptionist(&recpt);
246 recpt.add_browser (&avlistbrowserclass);
247 recpt.setdefaultbrowser ("VList");
248
249 hlistbrowserclass ahlistbrowserclass;
250 ahlistbrowserclass.set_receptionist(&recpt);
251 recpt.add_browser (&ahlistbrowserclass);
252
253#ifdef GSDL_USE_DATELIST_BROWSER
254 datelistbrowserclass adatelistbrowserclass;
255 recpt.add_browser (&adatelistbrowserclass);
256#endif
257
258 invbrowserclass ainvbrowserclass;
259 recpt.add_browser (&ainvbrowserclass);
260
261#ifdef GSDL_USE_PAGED_BROWSER
262 pagedbrowserclass apagedbrowserclass;
263 recpt.add_browser (&apagedbrowserclass);
264#endif
265
266#ifdef GSDL_USE_HTML_BROWSER
267 htmlbrowserclass ahtmlbrowserclass;
268 recpt.add_browser (&ahtmlbrowserclass);
269#endif
270
271#ifdef GSDL_USE_PHIND_BROWSER
272 phindbrowserclass aphindbrowserclass;
273 recpt.add_browser (&aphindbrowserclass);
274#endif
275
276#ifdef GSDL_USE_CLASSIFIER_BROWSER
277 //list of classifier browsers
278 CTreeClassifierBrowserClass *pTreeClassifierBrowser = new CTreeClassifierBrowserClass();
279 if (pTreeClassifierBrowser != NULL) {
280 recpt.GetClassifierBrowsers().AddBrowser(pTreeClassifierBrowser);
281 recpt.GetClassifierBrowsers().SetDefaultBrowser(pTreeClassifierBrowser->GetBrowserName());
282 }
283#ifdef GSDL_USE_TREE_EX_CLASSIFIER_BROWSER
284 CTreeExClassifierBrowserClass *pTreeExClassifierBrowser = new CTreeExClassifierBrowserClass();
285 if (pTreeExClassifierBrowser != NULL) {
286 recpt.GetClassifierBrowsers().AddBrowser(pTreeExClassifierBrowser);
287 }
288#endif //GSDL_USE_TREE_EX_CLASSIFIER_BROWSER
289#endif //GSDL_USE_CLASSIFIER_BROWSER
290
291 cgiwrapper (recpt, "");
292 delete cservers;
293 delete udb;
294 delete kdb;
295
296 // clean up the actions
297 actionmapclass::iterator thisAction = recpt.get_actionmap_ptr()->begin();
298 actionmapclass::iterator endAction = recpt.get_actionmap_ptr()->begin();
299 while (thisAction != endAction) {
300 delete thisAction->second.a; thisAction->second.a = NULL;
301 ++thisAction;
302 }
303 thisAction = recpt.get_actionmap_ptr()->begin();
304 recpt.get_actionmap_ptr()->erase(thisAction, endAction);
305
306 return 0;
307}
308
309
310
311
312
313
314
Note: See TracBrowser for help on using the repository browser.