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

Last change on this file since 22067 was 22067, checked in by ak19, 14 years ago
  1. More changes to makefiles: rm JDBMWrapper.jar and jdbm.jar on clean. 2. DB files (argdb, users, key, history) now not only for gdbm but to work with other db types like jdbm, sqlite and mssql.
  • Property svn:keywords set to Author Date Id Revision
File size: 7.5 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 userdbclass *udb = new userdbclass(gsdlhome);
160 keydbclass *kdb = new keydbclass(gsdlhome);
161
162#ifdef GSDL_USE_USERS_ACTION
163 usersaction *ausersaction = new usersaction();
164 ausersaction->set_userdb(udb);
165 recpt.add_action (ausersaction);
166#endif
167
168#ifdef GSDL_USE_EXTLINK_ACTION
169 extlinkaction *aextlinkaction = new extlinkaction();
170 aextlinkaction->set_receptionist(&recpt);
171 recpt.add_action (aextlinkaction);
172#endif
173
174#ifdef GSDL_USE_AUTHEN_ACTION
175 authenaction *aauthenaction = new authenaction();
176 aauthenaction->set_userdb(udb);
177 aauthenaction->set_keydb(kdb);
178 aauthenaction->set_receptionist(&recpt);
179 recpt.add_action (aauthenaction);
180#endif
181
182#ifdef GSDL_USE_COLLECTOR_ACTION
183 collectoraction *acollectoraction = new collectoraction();
184 acollectoraction->set_receptionist (&recpt);
185 recpt.add_action(acollectoraction);
186#endif
187
188#ifdef GSDL_USE_DEPOSITOR_ACTION
189 depositoraction *adepositoraction = new depositoraction();
190 adepositoraction->set_receptionist (&recpt);
191 recpt.add_action(adepositoraction);
192#endif
193
194#ifdef GSDL_USE_BROWSE_ACTION
195 browseaction *abrowseaction = new browseaction();
196 abrowseaction->set_receptionist (&recpt);
197 recpt.add_action(abrowseaction);
198#endif
199
200#ifdef GSDL_USE_PHIND_ACTION
201 recpt.add_action(new phindaction());
202#endif
203
204#ifdef GSDL_USE_GTI_ACTION
205 gtiaction *agtiaction = new gtiaction();
206 agtiaction->set_receptionist(&recpt);
207 recpt.add_action(agtiaction);
208#endif
209
210 dynamicclassifieraction *adynamicclassifieraction = new dynamicclassifieraction();
211 adynamicclassifieraction->set_receptionist(&recpt);
212 recpt.add_action(adynamicclassifieraction);
213
214 // list of browsers
215 vlistbrowserclass avlistbrowserclass;
216 avlistbrowserclass.set_receptionist(&recpt);
217 recpt.add_browser (&avlistbrowserclass);
218 recpt.setdefaultbrowser ("VList");
219
220 hlistbrowserclass ahlistbrowserclass;
221 ahlistbrowserclass.set_receptionist(&recpt);
222 recpt.add_browser (&ahlistbrowserclass);
223
224#ifdef GSDL_USE_DATELIST_BROWSER
225 datelistbrowserclass adatelistbrowserclass;
226 recpt.add_browser (&adatelistbrowserclass);
227#endif
228
229 invbrowserclass ainvbrowserclass;
230 recpt.add_browser (&ainvbrowserclass);
231
232#ifdef GSDL_USE_PAGED_BROWSER
233 pagedbrowserclass apagedbrowserclass;
234 recpt.add_browser (&apagedbrowserclass);
235#endif
236
237#ifdef GSDL_USE_HTML_BROWSER
238 htmlbrowserclass ahtmlbrowserclass;
239 recpt.add_browser (&ahtmlbrowserclass);
240#endif
241
242#ifdef GSDL_USE_PHIND_BROWSER
243 phindbrowserclass aphindbrowserclass;
244 recpt.add_browser (&aphindbrowserclass);
245#endif
246
247 cgiwrapper (recpt, "");
248 delete cservers;
249 delete udb;
250 delete kdb;
251
252 // clean up the actions
253 actionmapclass::iterator thisAction = recpt.get_actionmap_ptr()->begin();
254 actionmapclass::iterator endAction = recpt.get_actionmap_ptr()->begin();
255 while (thisAction != endAction) {
256 delete thisAction->second.a; thisAction->second.a = NULL;
257 ++thisAction;
258 }
259 thisAction = recpt.get_actionmap_ptr()->begin();
260 recpt.get_actionmap_ptr()->erase(thisAction, endAction);
261
262 return 0;
263}
Note: See TracBrowser for help on using the repository browser.