root/gsdl/trunk/src/recpt/librarymain.cpp @ 16310

Revision 16310, 7.4 KB (checked in by davidb, 11 years ago)

Introduction of 'collecthome' which parallels 'gsdlhome' to allow the toplevel collect folder to be outside of the gsdlhome area

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