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

Last change on this file since 11998 was 11998, checked in by davidb, 18 years ago

First cut at 'The Depositor' -- Greenstone support for institutional
repositories

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