source: main/trunk/greenstone2/runtime-src/src/recpt/librarymain.cpp@ 22058

Last change on this file since 22058 was 22046, checked in by davidb, 14 years ago

Changes necessary to support new sql-query action

  • Property svn:keywords set to Author Date Id Revision
File size: 7.6 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 "collectset.h"
36
37#include "action.h"
38#include "authenaction.h"
39#include "browseaction.h"
40#include "collectoraction.h"
41#include "depositoraction.h"
42#include "documentaction.h"
43#include "dynamicclassifieraction.h"
44#include "extlinkaction.h"
45#include "pageaction.h"
46#ifdef ENABLE_MGPP
47#include "phindaction.h"
48#endif
49#include "pingaction.h"
50#include "queryaction.h"
51
52#if defined(USE_SQLITE)
53#include "sqlqueryaction.h"
54#endif
55
56#include "tipaction.h"
57#include "statusaction.h"
58#include "usersaction.h"
59
60#include "browserclass.h"
61#include "vlistbrowserclass.h"
62#include "hlistbrowserclass.h"
63#include "datelistbrowserclass.h"
64#include "invbrowserclass.h"
65#include "pagedbrowserclass.h"
66#include "htmlbrowserclass.h"
67#include "phindbrowserclass.h"
68
69
70int main ()
71{
72 receptionist recpt;
73 nullproto nproto;
74 collectset *cservers;
75#if defined(USE_Z3950)
76 z3950proto zproto;
77#endif
78 text_t gsdlhome;
79 text_t collecthome;
80
81 cservers = new collectset(gsdlhome,collecthome);
82
83 // configure the receptionist server list
84 text_tarray collection_list;
85 cservers->getCollectionList(collection_list);
86 text_tarray::iterator collection_iterator = collection_list.begin();
87 while (collection_iterator != collection_list.end())
88 {
89 text_tarray colinfo;
90 colinfo.push_back(*collection_iterator);
91 colinfo.push_back(gsdlhome);
92 colinfo.push_back(collecthome);
93 colinfo.push_back(gsdlhome);
94 recpt.configure("collectinfo", colinfo);
95 collection_iterator++;
96 }
97
98 // set up the null protocol
99 nproto.set_collectset(cservers);
100
101 // add the protocol to the receptionist
102 recpt.add_protocol (&nproto);
103
104 // z39.50 stuff - johnmcp
105#if defined(USE_Z3950)
106 // add the z39.50 server information. Read in the file
107 // etc/packages/z3950/z3950.cfg for list of servers and their databases.
108 text_t z3950cfg = filename_cat (gsdlhome, "etc", "packages", "z3950", "z3950.cfg");
109#ifdef USE_FASTCGI
110 // currently can't use z39.50 if fastcgi used
111#warning "Disabling z39.50 support as fastcgi is in use"
112 if (0) {
113#else
114 if (file_exists(z3950cfg)) {
115#endif
116 text_t z3950err = filename_cat (gsdlhome, "etc", "packages", "z3950", "z3950log.txt");
117 zproto.read_config_file(z3950cfg,z3950err);
118 // only add this protocol if we have any servers configured.
119 if (zproto.getServerCount()>0)
120 recpt.add_protocol (&zproto);
121 }
122#endif
123
124 // the list of actions. Note: these actions will become invalid
125 // at the end of this function. We will clean them.
126
127#ifdef GSDL_USE_TIP_ACTION
128 recpt.add_action (new tipaction());
129#endif
130
131#ifdef GSDL_USE_STATUS_ACTION
132 statusaction *astatusaction = new statusaction();
133 astatusaction->set_receptionist (&recpt);
134 recpt.add_action (astatusaction);
135#endif
136
137 pageaction *apageaction = new pageaction();
138 apageaction->set_receptionist (&recpt);
139 recpt.add_action (apageaction);
140
141#ifdef GSDL_USE_PING_ACTION
142 recpt.add_action (new pingaction());
143#endif
144
145 queryaction *aqueryaction = new queryaction();
146 aqueryaction->set_receptionist (&recpt);
147 recpt.add_action (aqueryaction);
148
149#if defined(USE_SQLITE)
150 sqlqueryaction *asqlqueryaction = new sqlqueryaction();
151 asqlqueryaction->set_receptionist (&recpt);
152 recpt.add_action (asqlqueryaction);
153#endif
154
155 documentaction *adocumentaction = new documentaction();
156 adocumentaction->set_receptionist (&recpt);
157 recpt.add_action (adocumentaction);
158
159 text_t userdbfile = filename_cat(gsdlhome, "etc", "users.gdb");
160 userdbclass *udb = new userdbclass(userdbfile);
161
162 text_t keydbfile = filename_cat(gsdlhome, "etc", "key.gdb");
163 keydbclass *kdb = new keydbclass(keydbfile);
164
165#ifdef GSDL_USE_USERS_ACTION
166 usersaction *ausersaction = new usersaction();
167 ausersaction->set_userdb(udb);
168 recpt.add_action (ausersaction);
169#endif
170
171#ifdef GSDL_USE_EXTLINK_ACTION
172 extlinkaction *aextlinkaction = new extlinkaction();
173 aextlinkaction->set_receptionist(&recpt);
174 recpt.add_action (aextlinkaction);
175#endif
176
177#ifdef GSDL_USE_AUTHEN_ACTION
178 authenaction *aauthenaction = new authenaction();
179 aauthenaction->set_userdb(udb);
180 aauthenaction->set_keydb(kdb);
181 aauthenaction->set_receptionist(&recpt);
182 recpt.add_action (aauthenaction);
183#endif
184
185#ifdef GSDL_USE_COLLECTOR_ACTION
186 collectoraction *acollectoraction = new collectoraction();
187 acollectoraction->set_receptionist (&recpt);
188 recpt.add_action(acollectoraction);
189#endif
190
191#ifdef GSDL_USE_DEPOSITOR_ACTION
192 depositoraction *adepositoraction = new depositoraction();
193 adepositoraction->set_receptionist (&recpt);
194 recpt.add_action(adepositoraction);
195#endif
196
197#ifdef GSDL_USE_BROWSE_ACTION
198 browseaction *abrowseaction = new browseaction();
199 abrowseaction->set_receptionist (&recpt);
200 recpt.add_action(abrowseaction);
201#endif
202
203#ifdef GSDL_USE_PHIND_ACTION
204 recpt.add_action(new phindaction());
205#endif
206
207#ifdef GSDL_USE_GTI_ACTION
208 gtiaction *agtiaction = new gtiaction();
209 agtiaction->set_receptionist(&recpt);
210 recpt.add_action(agtiaction);
211#endif
212
213 dynamicclassifieraction *adynamicclassifieraction = new dynamicclassifieraction();
214 adynamicclassifieraction->set_receptionist(&recpt);
215 recpt.add_action(adynamicclassifieraction);
216
217 // list of browsers
218 vlistbrowserclass avlistbrowserclass;
219 avlistbrowserclass.set_receptionist(&recpt);
220 recpt.add_browser (&avlistbrowserclass);
221 recpt.setdefaultbrowser ("VList");
222
223 hlistbrowserclass ahlistbrowserclass;
224 ahlistbrowserclass.set_receptionist(&recpt);
225 recpt.add_browser (&ahlistbrowserclass);
226
227#ifdef GSDL_USE_DATELIST_BROWSER
228 datelistbrowserclass adatelistbrowserclass;
229 recpt.add_browser (&adatelistbrowserclass);
230#endif
231
232 invbrowserclass ainvbrowserclass;
233 recpt.add_browser (&ainvbrowserclass);
234
235#ifdef GSDL_USE_PAGED_BROWSER
236 pagedbrowserclass apagedbrowserclass;
237 recpt.add_browser (&apagedbrowserclass);
238#endif
239
240#ifdef GSDL_USE_HTML_BROWSER
241 htmlbrowserclass ahtmlbrowserclass;
242 recpt.add_browser (&ahtmlbrowserclass);
243#endif
244
245#ifdef GSDL_USE_PHIND_BROWSER
246 phindbrowserclass aphindbrowserclass;
247 recpt.add_browser (&aphindbrowserclass);
248#endif
249
250 cgiwrapper (recpt, "");
251 delete cservers;
252 delete udb;
253 delete kdb;
254
255 // clean up the actions
256 actionmapclass::iterator thisAction = recpt.get_actionmap_ptr()->begin();
257 actionmapclass::iterator endAction = recpt.get_actionmap_ptr()->begin();
258 while (thisAction != endAction) {
259 delete thisAction->second.a; thisAction->second.a = NULL;
260 ++thisAction;
261 }
262 thisAction = recpt.get_actionmap_ptr()->begin();
263 recpt.get_actionmap_ptr()->erase(thisAction, endAction);
264
265 return 0;
266}
Note: See TracBrowser for help on using the repository browser.