source: trunk/gsdl/src/recpt/statusaction.cpp@ 1266

Last change on this file since 1266 was 1266, checked in by nzdl, 24 years ago

fixed a few errors in the macro files (and one in some text printed out
by the statusaction)

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 35.8 KB
Line 
1/**********************************************************************
2 *
3 * statusaction.cpp --
4 * Copyright (C) 1999 The New Zealand 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 * $Id: statusaction.cpp 1266 2000-07-03 22:26:32Z nzdl $
25 *
26 *********************************************************************/
27
28/*
29 $Log$
30 Revision 1.30 2000/07/03 22:26:27 nzdl
31 fixed a few errors in the macro files (and one in some text printed out
32 by the statusaction)
33
34 Revision 1.29 2000/06/29 02:47:21 sjboddie
35 added browser info (i.e VList, HList etc.) to status pages
36
37 Revision 1.28 2000/06/29 00:22:59 sjboddie
38 added new numsections field to collection info and made the statusaction
39 recognize it
40
41 Revision 1.27 2000/05/12 03:09:24 sjboddie
42 minor modifications to get web library compiling under VC++ 6.0
43
44 Revision 1.26 2000/04/19 22:30:23 sjboddie
45 tidied up status pages and end-user collection building
46
47 Revision 1.25 2000/02/29 21:00:31 sjboddie
48 fixed some compiler warnings
49
50 Revision 1.24 1999/12/06 01:13:02 sjboddie
51 macrofiles is now a set to allow for multiple gsdlhomes
52
53 Revision 1.23 1999/11/09 02:26:20 sjboddie
54 added some new(ish) options
55
56 Revision 1.22 1999/11/01 21:55:27 sjboddie
57 changes to arguments of many functions
58
59 Revision 1.21 1999/10/19 03:23:46 davidb
60 Collection building support through web pages
61 and internal and external link handling for collection documents
62
63 Revision 1.20 1999/10/18 20:10:41 sjboddie
64 don't want to use authentication to reach status page (usersaction still
65 uses authentication)
66
67 Revision 1.19 1999/09/07 23:09:40 rjmcnab
68 removed some compiler warnings
69
70 Revision 1.18 1999/09/07 04:57:00 sjboddie
71 added GPL notice
72
73 Revision 1.17 1999/09/03 09:53:46 rjmcnab
74 Output more configuration options for the receptionist.
75
76 Revision 1.16 1999/09/02 00:28:42 rjmcnab
77 removed dependancy on GSDL_GSDLHOME
78
79 Revision 1.15 1999/07/30 02:24:42 sjboddie
80 added collectinfo argument to some functions
81
82 Revision 1.14 1999/07/13 23:26:07 rjmcnab
83 Added support for authenaction and usersaction
84
85 Revision 1.13 1999/06/08 04:29:39 sjboddie
86 added argsinfo to the call to check_cgiargs to make it easy to set
87 args to their default if they're found to be screwed up
88
89 Revision 1.12 1999/04/06 22:20:35 rjmcnab
90 Got browsefilter working.
91
92 Revision 1.11 1999/03/31 23:44:49 rjmcnab
93 Altered the protocol so that the metadata is part of the filter.
94
95 Revision 1.10 1999/03/16 04:47:03 rjmcnab
96 Changed the list of arguments on the argument page to be the info list
97 not the current args list (there are some arguments which don't have
98 a default so they never make it onto the args list).
99
100 Revision 1.9 1999/03/11 01:26:02 rjmcnab
101 Fixed a few small formatting things.
102
103 Revision 1.8 1999/03/11 00:12:30 rjmcnab
104 Started using status.dm to handle the bulky text. Made the status
105 action use frames and added some more information.
106
107 Revision 1.7 1999/03/09 21:00:47 rjmcnab
108 Reorganised the statusaction, added more functions to comtypes.
109
110 Revision 1.6 1999/02/25 21:59:02 rjmcnab
111
112 Merged sources.
113
114 Revision 1.5 1999/02/21 22:33:58 rjmcnab
115
116 Lots of stuff :-)
117
118 Revision 1.4 1999/02/12 02:40:18 sjboddie
119
120 Added page action
121
122 Revision 1.3 1999/02/11 23:07:00 sjboddie
123
124 extended the status action
125
126 Revision 1.2 1999/02/11 01:24:06 rjmcnab
127
128 Fixed a few compiler warnings.
129
130 Revision 1.1 1999/02/11 01:01:27 rjmcnab
131
132 Initial revision.
133
134 */
135
136#include "statusaction.h"
137#include "fileutil.h"
138#include "htmlutils.h"
139#include <assert.h>
140
141
142void statusaction::output_frameset (cgiargsclass &/*args*/, displayclass &disp,
143 outconvertclass &outconvert,
144 ostream &textout, ostream &/*logout*/) {
145 textout << outconvert << disp << "_status:frameset_\n";
146}
147
148void statusaction::output_select (cgiargsclass &/*args*/, displayclass &disp,
149 outconvertclass &outconvert,
150 ostream &textout, ostream &/*logout*/) {
151 textout << outconvert << disp << "_status:header_(selector)\n"
152 "_status:select_\n"
153 "_status:footer_\n";
154}
155
156void statusaction::output_welcome (cgiargsclass &/*args*/, recptprotolistclass *protos,
157 displayclass &disp, outconvertclass &outconvert,
158 ostream &textout, ostream &logout) {
159
160 textout << outconvert << disp
161 << "_status:infoheader_(_titlewelcome_)\n"
162 << "_status:welcome_"
163 << "<center><table width=_pagewidth_>\n"
164 << "<th align=left>abbrev.</th><th align=left>collection</th>"
165 << "<th align=left>public?</th><th align=left>running?</th></tr>\n";
166
167 recptprotolistclass::iterator rprotolist_here = protos->begin();
168 recptprotolistclass::iterator rprotolist_end = protos->end();
169 while (rprotolist_here != rprotolist_end) {
170 if ((*rprotolist_here).p != NULL) {
171 text_t protoname = (*rprotolist_here).p->get_protocol_name();
172 text_tarray collist;
173 comerror_t err;
174 (*rprotolist_here).p->get_collection_list (collist, err, logout);
175 if (err == noError) {
176 text_tarray::iterator collist_here = collist.begin();
177 text_tarray::iterator collist_end = collist.end();
178
179 while (collist_here != collist_end) {
180
181 textout << outconvert << disp
182 << "<tr><td><a href=\"_gwcgi_?e=_compressedoptions_&a=status&sp=collectioninfo&pr="
183 << protoname
184 << "&c="
185 << *collist_here
186 << "\">"
187 << *collist_here
188 << "</a></td>";
189
190 ColInfoResponse_t cinfo;
191 (*rprotolist_here).p->get_collectinfo (*collist_here, cinfo, err, logout);
192 if (err == noError) {
193 text_t collname = *collist_here;
194 text_tmap::iterator it = cinfo.collectionmeta.find("collectionname");
195 if (it != cinfo.collectionmeta.end()) collname = (*it).second;
196
197 textout << "<td>";
198 if (cinfo.buildDate > 0)
199 textout << outconvert << disp
200 << "<a href=\"_httppagex_(about)&c=" << *collist_here
201 << "\" target=\\_top>";
202
203 textout << outconvert << disp << collname;
204
205 if (cinfo.buildDate > 0) textout << "</a>";
206
207 textout << "</td>";
208
209 if (cinfo.isPublic) textout << "<td>yes</td>";
210 else textout << "<td>no</td>";
211
212 if (cinfo.buildDate > 0)
213 textout << outconvert << "<td>yes</td>";
214 else
215 textout << "<td>no</td>";
216
217 } else {
218 textout << "<td></td><td></td><td></td>";
219 }
220
221 textout << "</tr>\n";
222 collist_here ++;
223 }
224 }
225 }
226 rprotolist_here ++;
227 }
228
229 textout << "</table></center>\n";
230 textout << outconvert << disp << "_status:infofooter_\n";
231}
232
233void statusaction::output_generalinfo (cgiargsclass &/*args*/, displayclass &disp,
234 outconvertclass &outconvert,
235 ostream &textout, ostream &/*logout*/) {
236 if (recpt == NULL) return;
237 const recptconf &rcinfo = recpt->get_configinfo ();
238
239 textout << outconvert << disp << "_status:infoheader_(General Information)\n";
240 textout << outconvert
241 << "<h2>General information</h2>\n"
242 << "<table>\n"
243 << "<tr valign=top><th>gsdlhome</th><td>\"" << rcinfo.gsdlhome
244 << "\"</td></tr>\n"
245 << "<tr valign=top><th>collection</th><td>\"" << rcinfo.collection
246 << "\"</td></tr>\n"
247 << "<tr valign=top><th>collectdir</th><td>\"" << rcinfo.collectdir
248 << "\"</td></tr>\n"
249 << "<tr valign=top><th>httpprefix</th><td>\"" << rcinfo.httpprefix
250 << "\"</td></tr>\n"
251 << "<tr valign=top><th>httpimg</th><td>\"" << rcinfo.httpimg
252 << "\"</td></tr>\n"
253 << "<tr valign=top><th>gwcgi</th><td>\"" << rcinfo.gwcgi
254 << "\"</td></tr>\n";
255
256 // macrofiles
257 textout << outconvert << "<tr valign=top><th>macrofiles</th><td>";
258 text_tset::const_iterator macrohere = rcinfo.macrofiles.begin ();
259 text_tset::const_iterator macroend = rcinfo.macrofiles.end ();
260 bool macrofirst = true;
261 while (macrohere != macroend) {
262 if (!macrofirst) textout << outconvert << ", ";
263 macrofirst = false;
264 textout << outconvert << "\"" << *macrohere << "\"";
265 macrohere++;
266 }
267 textout << outconvert << "</td></tr>\n";
268
269 // saveconf
270 textout << outconvert << "<tr valign=top><th>saveconf</th><td>\"" << rcinfo.saveconf
271 << "\"</td></tr>\n";
272
273 // usecookies
274 textout << outconvert << "<tr valign=top><th>usecookies</th><td>\"";
275 if (rcinfo.usecookies) textout << outconvert << "true";
276 else textout << outconvert << "false";
277 textout << outconvert << "\"</td></tr>\n";
278
279 // logcgiargs
280 textout << outconvert << "<tr valign=top><th>logcgiargs</th><td>\"";
281 if (rcinfo.logcgiargs) textout << outconvert << "true";
282 else textout << outconvert << "false";
283 textout << outconvert << "\"</td></tr>\n";
284
285 // pageparams
286 textout << outconvert << "<tr valign=top><th>pageparams</th><td>";
287 text_tmap::const_iterator params_here = rcinfo.pageparams.begin();
288 text_tmap::const_iterator params_end = rcinfo.pageparams.end();
289 bool params_first = true;
290 while (params_here != params_end) {
291 if (!params_first) textout << outconvert << ", ";
292 params_first = false;
293 textout << outconvert << "\"" << (*params_here).first << "\" != \""
294 << (*params_here).second << "\"";
295
296 params_here++;
297 }
298 textout << outconvert << "</td></tr>\n";
299
300 // macroprecedence
301 textout << outconvert << "<tr valign=top><th>macroprecedence</th><td>\"" << rcinfo.macroprecedence
302 << "\"</td></tr>\n";
303
304 // arguments
305 cgiargsinfoclass *rcargsinfo = recpt->get_cgiargsinfo_ptr ();
306 if (rcargsinfo != NULL) {
307 textout << outconvert << "<tr valign=top><th>arguments</th><td>";
308
309 cgiargsinfoclass::const_iterator argsinfohere = rcargsinfo->begin ();
310 cgiargsinfoclass::const_iterator argsinfoend = rcargsinfo->end ();
311 bool argsinfofirst = true;
312 while (argsinfohere != argsinfoend) {
313 if (!argsinfofirst) textout << outconvert << ", ";
314 argsinfofirst = false;
315 textout << outconvert << "\"" << (*argsinfohere).second.shortname << "\"";
316 argsinfohere++;
317 }
318
319 textout << outconvert << "</td></tr>\n";
320 }
321
322 // actions
323 actionmapclass *actions = recpt->get_actionmap_ptr();
324 if (actions != NULL) {
325 textout << outconvert << "<tr valign=top><th>actions</th><td>";
326
327 actionptrmap::iterator actionshere = actions->begin ();
328 actionptrmap::iterator actionsend = actions->end ();
329 bool actionsfirst = true;
330 while (actionshere != actionsend) {
331 if (!actionsfirst) textout << outconvert << ", ";
332 actionsfirst = false;
333 assert ((*actionshere).second.a != NULL);
334 if ((*actionshere).second.a != NULL) {
335 textout << outconvert << "\"" << (*actionshere).second.a->get_action_name() << "\"";
336 }
337 actionshere++;
338 }
339
340 textout << outconvert << "</td></tr>\n";
341 }
342
343 // browsers
344 browsermapclass *browsers = recpt->get_browsermap_ptr();
345 if (browsers != NULL) {
346 textout << outconvert << "<tr valign=top><th>browsers</th><td>";
347
348 browserptrmap::iterator browsershere = browsers->begin ();
349 browserptrmap::iterator browsersend = browsers->end ();
350 bool browsersfirst = true;
351 while (browsershere != browsersend) {
352 if (!browsersfirst) textout << outconvert << ", ";
353 browsersfirst = false;
354 assert ((*browsershere).second.b != NULL);
355 if ((*browsershere).second.b != NULL) {
356 textout << outconvert << "\"" << (*browsershere).second.b->get_browser_name() << "\"";
357 }
358 browsershere++;
359 }
360
361 textout << outconvert << "</td></tr>\n";
362 }
363
364 // protocols
365 recptprotolistclass *protocols = recpt->get_recptprotolist_ptr ();
366 if (protocols != NULL) {
367 textout << outconvert << "<tr valign=top><th>protocols</th><td>";
368
369 recptprotolistclass::iterator protohere = protocols->begin ();
370 recptprotolistclass::iterator protoend = protocols->end ();
371 bool protofirst = true;
372 while (protohere != protoend) {
373 if (!protofirst) textout << outconvert << ", ";
374 protofirst = false;
375 if ((*protohere).p != NULL) {
376 textout << outconvert << "\"" << (*protohere).p->get_protocol_name() << "\"";
377 }
378 protohere++;
379 }
380
381 textout << outconvert << "</td></tr>\n";
382 }
383
384 // converters
385 convertinfoclass *converters = recpt->get_convertinfo_ptr ();
386 if (converters != NULL) {
387 textout << outconvert << "<tr valign=top><th>converters</th><td>";
388
389 convertinfoclass::iterator converthere = converters->begin ();
390 convertinfoclass::iterator convertend = converters->end ();
391 bool convertfirst = true;
392 while (converthere != convertend) {
393 if (!convertfirst) textout << outconvert << ", ";
394 convertfirst = false;
395 textout << outconvert << "\"" << (*converthere).second.name << "\"";
396 converthere++;
397 }
398
399 textout << outconvert << "</td></tr>\n";
400 }
401
402 textout << outconvert << disp << "</table>\n_status:infofooter_\n";
403}
404
405void statusaction::output_argumentinfo (cgiargsclass &args, displayclass &disp,
406 outconvertclass &outconvert,
407 ostream &textout, ostream &/*logout*/) {
408 if (recpt == NULL) return;
409 cgiargsinfoclass *rcargsinfo = recpt->get_cgiargsinfo_ptr ();
410 if (rcargsinfo == NULL) return;
411
412 textout << outconvert << disp << "_status:infoheader_(Argument Information)\n";
413 textout << outconvert
414 << "<h2>Argument information</h2>\n"
415 << "<table>";
416
417 // argument information
418 textout << outconvert << "<tr valign=top><th>short name</th><th>long name</th>"
419 << "<th>multiple char?</th>"
420 << "<th>multiple value?</th>"
421 << "<th>default</th><th>default status</th><th>saved args</th>"
422 << "<th>current value</th></tr>\n";
423
424
425 cgiargsinfoclass::const_iterator argsinfohere = rcargsinfo->begin();
426 cgiargsinfoclass::const_iterator argsinfoend = rcargsinfo->end();
427 text_t *arg_value;
428 while (argsinfohere != argsinfoend) {
429 const cgiarginfo &ainfo = (*argsinfohere).second;
430 textout << outconvert
431 << "<tr valign=top><td>" << ainfo.shortname << "</td>\n";
432
433 textout << outconvert << "<td>" << ainfo.longname << "</td>\n";
434 if (ainfo.multiplechar) textout << outconvert << "<td>yes</td>\n";
435 else textout << outconvert << "<td>no</td>\n";
436 if (ainfo.multiplevalue) textout << outconvert << "<td>yes</td>\n";
437 else textout << outconvert << "<td>no</td>\n";
438 textout << outconvert << "<td>" << ainfo.argdefault << "</td>\n";
439 switch (ainfo.defaultstatus) {
440 case cgiarginfo::none: textout << outconvert << "<td>none</td>\n"; break;
441 case cgiarginfo::weak: textout << outconvert << "<td>weak</td>\n"; break;
442 case cgiarginfo::good: textout << outconvert << "<td>good</td>\n"; break;
443 case cgiarginfo::config: textout << outconvert << "<td>config</td>\n"; break;
444 case cgiarginfo::imperative: textout << outconvert << "<td>imperative</td>\n"; break;
445 }
446 switch (ainfo.savedarginfo) {
447 case cgiarginfo::mustnot: textout << outconvert << "<td>mustnot</td>\n"; break;
448 case cgiarginfo::can: textout << outconvert << "<td>can</td>\n"; break;
449 case cgiarginfo::must: textout << outconvert << "<td>must</td>\n"; break;
450 }
451
452 arg_value = args.getarg (ainfo.shortname);
453 if (arg_value == NULL) textout << outconvert << "<td></td></tr>\n";
454 else textout << outconvert << "<td>\"" << *arg_value << "\"</td></tr>\n";
455
456 argsinfohere ++;
457 }
458
459 textout << outconvert << disp << "</table>\n_status:infofooter_\n";
460}
461
462void statusaction::output_actioninfo (cgiargsclass &/*args*/, displayclass &disp,
463 outconvertclass &outconvert,
464 ostream &textout, ostream &/*logout*/) {
465 if (recpt == NULL) return;
466 actionmapclass *actions = recpt->get_actionmap_ptr();
467
468 textout << outconvert << disp << "_status:infoheader_(Action Information)\n";
469 textout << outconvert
470 << "<h2>Action information</h2>\n"
471 << "<table>";
472
473 // action information
474 if (actions != NULL) {
475 textout << outconvert
476 << "<tr><th>action name</th><th>cgi arguments</th></tr>\n";
477
478 actionptrmap::iterator actionshere = actions->begin ();
479 actionptrmap::iterator actionsend = actions->end ();
480 while (actionshere != actionsend) {
481 assert ((*actionshere).second.a != NULL);
482 if ((*actionshere).second.a != NULL) {
483 textout << outconvert
484 << "<tr><td>" << (*actionshere).second.a->get_action_name()
485 << "</td><td>";
486
487 cgiargsinfoclass argsinfo = (*actionshere).second.a->getargsinfo();
488 cgiargsinfoclass::const_iterator argsinfohere = argsinfo.begin ();
489 cgiargsinfoclass::const_iterator argsinfoend = argsinfo.end ();
490 bool aifirst = true;
491 while (argsinfohere != argsinfoend) {
492 if (!aifirst) textout << outconvert << ", ";
493 aifirst = false;
494 textout << outconvert << (*argsinfohere).second.shortname;
495 argsinfohere++;
496 }
497
498 textout << outconvert << "</td></tr>\n";
499 }
500 actionshere++;
501 }
502 }
503
504 textout << outconvert << disp << "</table>\n_status:infofooter_\n";
505}
506
507void statusaction::output_browserinfo (cgiargsclass &/*args*/, displayclass &disp,
508 outconvertclass &outconvert,
509 ostream &textout, ostream &/*logout*/) {
510 if (recpt == NULL) return;
511 browsermapclass *browsers = recpt->get_browsermap_ptr();
512
513 textout << outconvert << disp << "_status:infoheader_(Browser Information)\n";
514 textout << outconvert
515 << "<h2>Browser information</h2>\n"
516 << "<table>";
517
518 // browser information
519 if (browsers != NULL) {
520 textout << outconvert
521 << "<tr><th>browser name</th><th>default formatstring</th></tr>\n";
522
523 browserptrmap::iterator browsershere = browsers->begin ();
524 browserptrmap::iterator browsersend = browsers->end ();
525 while (browsershere != browsersend) {
526 assert ((*browsershere).second.b != NULL);
527 if ((*browsershere).second.b != NULL) {
528 textout << outconvert
529 << "<tr><td>" << (*browsershere).second.b->get_browser_name()
530 << "</td><td>" << html_safe ((*browsershere).second.b->get_default_formatstring())
531 << "</td></tr>\n";
532 }
533 browsershere++;
534 }
535 }
536
537 textout << outconvert << disp << "</table>\n_status:infofooter_\n";
538}
539
540void statusaction::output_protocolinfo (cgiargsclass &/*args*/, displayclass &disp,
541 outconvertclass &outconvert,
542 ostream &textout, ostream &logout) {
543 if (recpt == NULL) return;
544 const recptconf &rcinfo = recpt->get_configinfo ();
545 bool colspecific = !rcinfo.collection.empty();
546 bool unreachablecol = false;
547
548 recptprotolistclass *rprotolist = recpt->get_recptprotolist_ptr ();
549 if (rprotolist == NULL) return;
550
551 textout << outconvert << disp << "_status:infoheader_(Protocol Information)\n";
552 textout << outconvert
553 << "<h2>Protocol information</h2>\n"
554 << "<table>\n"
555 << "<tr><th>protocol</th><th>collections</th></tr>\n";
556
557 text_t protoname;
558 recptprotolistclass::iterator rprotolist_here = rprotolist->begin();
559 recptprotolistclass::iterator rprotolist_end = rprotolist->end();
560 while (rprotolist_here != rprotolist_end) {
561 if ((*rprotolist_here).p != NULL) {
562 protoname = (*rprotolist_here).p->get_protocol_name();
563 textout << outconvert
564 << "<tr><td>"
565 << protoname
566 << "</td><td>";
567
568 text_tarray collist;
569 comerror_t err;
570 (*rprotolist_here).p->get_collection_list (collist, err, logout);
571 if (err == noError) {
572 text_tarray::iterator collist_here = collist.begin();
573 text_tarray::iterator collist_end = collist.end();
574 bool first = true;
575 while (collist_here != collist_end) {
576 if (!first) textout << outconvert << ", ";
577 first = false;
578
579 if (colspecific && *collist_here != rcinfo.collection) {
580 unreachablecol = true;
581 textout << outconvert << "\"" << *collist_here << "\"";
582 } else {
583 textout << outconvert << disp
584 << "\"<a href=\"_gwcgi_?e=_compressedoptions_&a=status&sp=collectioninfo&pr="
585 << protoname
586 << "&c="
587 << *collist_here
588 << "\">"
589 << *collist_here
590 << "</a>\"";
591 }
592
593 collist_here++;
594 }
595
596 } else {
597 textout << outconvert << "Error (" << get_comerror_string (err)
598 << ") while getting collect list\n";
599 }
600
601 textout << outconvert
602 << "</td></tr>\n";
603 }
604
605 rprotolist_here++;
606 }
607
608 textout << outconvert << "</table>\n";
609 if (unreachablecol) {
610 textout << outconvert
611 << "<b>Warning:</b> the receptionist is running in collection specific\n"
612 << "mode making some of the collections unreachable.\n";
613 }
614 textout << outconvert << disp << "_status:infofooter_\n";
615}
616
617void statusaction::output_collectioninfo (cgiargsclass &args, displayclass &disp,
618 outconvertclass &outconvert,
619 ostream &textout, ostream &logout) {
620 if (recpt == NULL) return;
621
622 textout << outconvert << disp << "_status:infoheader_(Collection info)\n";
623 textout << outconvert << "<h2>Collection info</h2>\n";
624
625 // get the list of protocols
626 recptprotolistclass *rprotolist = recpt->get_recptprotolist_ptr ();
627 if (rprotolist == NULL) return;
628
629 // look for the desired protocol
630 text_t &arg_pr = args["pr"];
631 text_t &arg_c = args["c"];
632 recptproto *rproto = NULL;
633 recptprotolistclass::iterator rprotolist_here = rprotolist->begin();
634 recptprotolistclass::iterator rprotolist_end = rprotolist->end();
635 while (rprotolist_here != rprotolist_end) {
636 rproto = (*rprotolist_here).p;
637 if (rproto != NULL && rproto->get_protocol_name() == arg_pr) {
638 // see if the protocol has the collection
639 bool hascollection;
640 comerror_t err;
641 rproto->has_collection (arg_c, hascollection, err, logout);
642 if (err == noError && hascollection) break;
643 }
644 rprotolist_here++;
645 }
646
647 if (rprotolist_here == rprotolist_end) {
648 textout << outconvert << "Protocol \"" << arg_pr << "\" with collection \""
649 << arg_c << "\" was not found\n";
650
651 } else {
652 // rproto can't be NULL to get here
653 ColInfoResponse_t collectinfo;
654 comerror_t err;
655
656 rproto->get_collectinfo (arg_c, collectinfo, err, logout);
657 if (err == noError) {
658 textout << outconvert << "<table>\n"
659 << "<tr><th>collection name</th><td>\""
660 << collectinfo.shortInfo.name
661 << "\"</td></tr>\n"
662
663 << "<tr><th>host</th><td>\""
664 << collectinfo.shortInfo.host
665 << "\"</td></tr>\n"
666
667 << "<tr><th>port</th><td>\""
668 << collectinfo.shortInfo.port
669 << "\"</td></tr>\n"
670
671 << "<tr><th>is public?</th><td>";
672 if (collectinfo.isPublic) textout << outconvert << "true";
673 else textout << outconvert << "false";
674 textout << outconvert
675 << "</td></tr>\n"
676
677 << "<tr><th>is beta?</th><td>";
678 if (collectinfo.isBeta) textout << outconvert << "true";
679 else textout << outconvert << "false";
680 textout << outconvert
681 << "</td></tr>\n"
682
683 << "<tr><th>build date</th><td>\""
684 << collectinfo.buildDate
685 << "\"</td></tr>\n"
686
687 << "<tr><th>interface languages</th><td>";
688 text_tarray::iterator languages_here = collectinfo.languages.begin();
689 text_tarray::iterator languages_end = collectinfo.languages.end();
690 bool languages_first = true;
691 while (languages_here != languages_end) {
692 if (!languages_first) textout << outconvert << ", ";
693 languages_first = false;
694 textout << outconvert << "\"" << *languages_here << "\"";
695 languages_here++;
696 }
697
698 textout << "<tr><th valign=top>collection metadata</th><td><table>\n";
699 text_tmap::iterator meta_here = collectinfo.collectionmeta.begin();
700 text_tmap::iterator meta_end = collectinfo.collectionmeta.end();
701 while (meta_here != meta_end) {
702 textout << outconvert << "<tr><td>" << (*meta_here).first
703 << "</td><td>" << (*meta_here).second << "</td></tr>\n";
704 meta_here ++;
705 }
706 textout << "</table></td></tr>\n";
707
708 textout << "<tr><th valign=top>format info</th><td><table>\n";
709 text_tmap::iterator format_here = collectinfo.format.begin();
710 text_tmap::iterator format_end = collectinfo.format.end();
711 while (format_here != format_end) {
712 textout << outconvert << "<tr><td>" << (*format_here).first
713 << "</td><td>" << html_safe((*format_here).second) << "</td></tr>\n";
714 format_here ++;
715 }
716 textout << "</table></td></tr>\n";
717
718 textout << "<tr><th valign=top>building info</th><td><table>\n";
719 text_tmap::iterator building_here = collectinfo.building.begin();
720 text_tmap::iterator building_end = collectinfo.building.end();
721 while (building_here != building_end) {
722 textout << outconvert << "<tr><td>" << (*building_here).first
723 << "</td><td>" << (*building_here).second << "</td></tr>\n";
724 building_here ++;
725 }
726 textout << "</table></td></tr>\n";
727
728 textout << outconvert
729 << "</td></tr>\n"
730
731 << "<tr><th>number of documents</th><td>\""
732 << collectinfo.numDocs
733 << "\"</td></tr>\n"
734
735 << "<tr><th>number of sections</th><td>\""
736 << collectinfo.numSections
737 << "\"</td></tr>\n"
738
739 << "<tr><th>number of words</th><td>\""
740 << collectinfo.numWords
741 << "\"</td></tr>\n"
742
743 << "<tr><th>number of bytes</th><td>\""
744 << collectinfo.numBytes
745 << "\"</td></tr>\n"
746
747 << "<tr><th>preferred receptionist</th><td>\""
748 << collectinfo.receptionist
749 << "\"</td></tr>\n"
750
751 << "</table>";
752
753 } else {
754 textout << outconvert << "Error (" << get_comerror_string (err)
755 << ") while getting collect information\n";
756 }
757
758
759 InfoFiltersResponse_t filterinfo;
760 InfoFilterOptionsRequest_t filteroptions_request;
761 InfoFilterOptionsResponse_t filteroptions;
762 rproto->get_filterinfo (arg_c, filterinfo, err, logout);
763 if (err == noError) {
764 text_tset::iterator filternames_here = filterinfo.filterNames.begin();
765 text_tset::iterator filternames_end = filterinfo.filterNames.end();
766 while (filternames_here != filternames_end) {
767 textout << outconvert
768 << "<hr>\n"
769 << "<h3>Filter options for \"" << (*filternames_here) << "\"</h3>\n"
770 << "<table>\n"
771 << "<tr><th>option name</th><th>type</th><th>repeatable</th>"
772 << "<th>default value</th><th>valid values</th></tr>\n";
773
774 filteroptions_request.clear();
775 filteroptions_request.filterName = *filternames_here;
776 rproto->get_filteroptions (arg_c, filteroptions_request,
777 filteroptions, err, logout);
778 if (err == noError) {
779 FilterOption_tmap::iterator filteropt_here =
780 filteroptions.filterOptions.begin();
781 FilterOption_tmap::iterator filteropt_end =
782 filteroptions.filterOptions.end();
783 while (filteropt_here != filteropt_end) {
784 textout << outconvert
785 << "<tr><td>\""
786 << (*filteropt_here).second.name
787 << "\"</td>\n"
788
789 << "<td>";
790 text_t type_string;
791 switch ((*filteropt_here).second.type) {
792 case FilterOption_t::booleant: type_string = "boolean"; break;
793 case FilterOption_t::integert: type_string = "integer"; break;
794 case FilterOption_t::enumeratedt: type_string = "enumerated"; break;
795 case FilterOption_t::stringt: type_string = "string"; break;
796 }
797 textout << outconvert
798 << type_string
799 << "</td>\n"
800
801 << "<td>";
802 text_t repeat_string;
803 switch ((*filteropt_here).second.repeatable) {
804 case FilterOption_t::onePerQuery: repeat_string = "one per query"; break;
805 case FilterOption_t::onePerTerm: repeat_string = "one per term"; break;
806 case FilterOption_t::nPerTerm: repeat_string = "n per term"; break;
807 }
808 textout << outconvert
809 << repeat_string
810 << "</td>\n"
811
812 << "<td>\""
813 << (*filteropt_here).second.defaultValue
814 << "\"</td>\n"
815
816 << "<td>";
817
818 text_tarray::iterator valid_here =
819 (*filteropt_here).second.validValues.begin();
820 text_tarray::iterator valid_end =
821 (*filteropt_here).second.validValues.end();
822 bool valid_first = true;
823 while (valid_here != valid_end) {
824 if (!valid_first) textout << outconvert << ", ";
825 valid_first = false;
826 textout << outconvert << "\"" << *valid_here << "\"";
827 valid_here++;
828 }
829 textout << outconvert
830 << "</td></tr>\n";
831
832 filteropt_here++;
833 }
834
835 textout << outconvert
836 << "</table>\n";
837
838 } else {
839 textout << outconvert << "Error (" << get_comerror_string (err)
840 << ") while getting filter option information\n";
841 }
842
843 filternames_here++;
844 }
845
846 } else {
847 textout << outconvert << "Error (" << get_comerror_string (err)
848 << ") while getting filter information\n";
849 }
850 }
851
852 textout << outconvert << disp << "_status:infofooter_\n";
853}
854
855void statusaction::output_initlog (cgiargsclass &/*args*/, displayclass &disp,
856 outconvertclass &outconvert,
857 ostream &textout, ostream &/*logout*/) {
858 if (recpt == NULL) return;
859 const recptconf &rcinfo = recpt->get_configinfo ();
860 text_t initfilename = filename_cat (rcinfo.gsdlhome, "etc", "initout.txt");
861 char *cinitfilename = initfilename.getcstr();
862 if (cinitfilename == NULL) return;
863
864 textout << outconvert << disp << "_status:infoheader_(Init log)\n";
865 textout << outconvert << "<h2>Init log</h2>\n";
866
867#ifdef GSDL_USE_IOS_H
868 ifstream initin (cinitfilename, ios::in | ios::nocreate);
869#else
870 ifstream initin (cinitfilename, ios::in);
871#endif
872
873 delete cinitfilename;
874 if (initin) {
875 textout << outconvert << "<p>The initialisation error log, "
876 << initfilename << ", contains the\n";
877 textout << outconvert << "following information:\n\n";
878 text_t errorpage = "<p><pre>\n";
879
880 char c;
881 initin.get(c);
882 while (!initin.eof ()) {
883 errorpage.push_back(c);
884 initin.get(c);
885 }
886
887 errorpage += "</pre>\n";
888 initin.close();
889 textout << outconvert << errorpage;
890
891 } else {
892 textout << outconvert << "Couldn't read initialisation error log, "
893 << initfilename << ".\n";
894 }
895
896 textout << outconvert << disp << "_status:infofooter_\n";
897}
898
899void statusaction::output_errorlog (cgiargsclass &/*args*/, displayclass &disp,
900 outconvertclass &outconvert,
901 ostream &textout, ostream &logout) {
902 if (recpt == NULL) return;
903 const recptconf &rcinfo = recpt->get_configinfo ();
904 text_t errfilename = filename_cat (rcinfo.gsdlhome, "etc", "errout.txt");
905 char *cerrfilename = errfilename.getcstr();
906 if (cerrfilename == NULL) return;
907
908 textout << outconvert << disp << "_status:infoheader_(Error log)\n";
909 textout << outconvert << "<h2>Error log</h2>\n";
910 logout << flush;
911
912#ifdef GSDL_USE_IOS_H
913 ifstream errin (cerrfilename, ios::in | ios::nocreate);
914#else
915 ifstream errin (cerrfilename, ios::in);
916#endif
917
918 delete cerrfilename;
919 if (errin) {
920 textout << outconvert << "<p>The error log, "
921 << errfilename << ", contains the\n";
922 textout << outconvert << "following information:\n\n";
923 text_t errorpage = "<p><pre>\n";
924
925 char c;
926 errin.get(c);
927 while (!errin.eof ()) {
928 errorpage.push_back(c);
929 errin.get(c);
930 }
931
932 errorpage += "</pre>\n";
933 errin.close();
934 textout << outconvert << errorpage;
935
936 } else {
937 textout << outconvert << "Couldn't read error log, "
938 << errfilename << ".\n";
939 }
940
941 textout << outconvert << disp << "_status:infofooter_\n";
942}
943
944void statusaction::output_errorpage (outconvertclass &outconvert,
945 ostream &textout, ostream &/*logout*/,
946 text_t message) {
947 textout << outconvert
948 << "<html>\n"
949 << "<head>\n"
950 << "<title>Error</title>\n"
951 << "</head>\n"
952 << "<body bgcolor=\"#ffffff\" text=\"#000000\" link=\"#006666\" "
953 << "alink=\"#cc9900\" vlink=\"#666633\">\n"
954 << "<h2>Oops!</h2>\n"
955 << message
956 << "\n</body>\n"
957 << "</html>\n";
958 return;
959}
960
961
962
963statusaction::statusaction () {
964 disabled = true;
965 recpt = NULL;
966
967 // this action uses cgi variable "a"
968 cgiarginfo arg_ainfo;
969 arg_ainfo.shortname = "a";
970 arg_ainfo.longname = "action";
971 arg_ainfo.multiplechar = true;
972 arg_ainfo.defaultstatus = cgiarginfo::weak;
973 arg_ainfo.argdefault = "status";
974 arg_ainfo.savedarginfo = cgiarginfo::must;
975 argsinfo.addarginfo (NULL, arg_ainfo);
976
977 // "sp" -- status page
978 arg_ainfo.shortname = "sp";
979 arg_ainfo.longname = "status page";
980 arg_ainfo.multiplechar = true;
981 arg_ainfo.defaultstatus = cgiarginfo::good;
982 arg_ainfo.argdefault = "frameset";
983 arg_ainfo.savedarginfo = cgiarginfo::can;
984 argsinfo.addarginfo (NULL, arg_ainfo);
985
986 // "pr" -- protocol
987 arg_ainfo.shortname = "pr";
988 arg_ainfo.longname = "protocol";
989 arg_ainfo.multiplechar = true;
990 arg_ainfo.defaultstatus = cgiarginfo::none;
991 arg_ainfo.argdefault = "";
992 arg_ainfo.savedarginfo = cgiarginfo::can;
993 argsinfo.addarginfo (NULL, arg_ainfo);
994}
995
996statusaction::~statusaction () {
997}
998
999bool statusaction::check_cgiargs (cgiargsinfoclass &/*argsinfo*/, cgiargsclass &/*args*/,
1000 ostream &/*logout*/) {
1001 return true;
1002}
1003
1004void statusaction::get_cgihead_info (cgiargsclass &/*args*/, recptprotolistclass * /*protos*/,
1005 response_t &response, text_t &response_data,
1006 ostream &/*logout*/) {
1007 response = content;
1008 response_data = "text/html";
1009}
1010
1011bool statusaction::do_action (cgiargsclass &args, recptprotolistclass *protos,
1012 browsermapclass * /*browsers*/, displayclass &disp,
1013 outconvertclass &outconvert, ostream &textout,
1014 ostream &logout) {
1015 // make sure the status function is enabled
1016 if (disabled) {
1017 output_errorpage (outconvert, textout, logout,
1018 "The status action is disabled. "
1019 "See the documentation (what documentation!) on how "
1020 "to enable it.");
1021 return true;
1022 }
1023
1024 // make sure we know about a receptionist
1025 if (recpt == NULL) {
1026 output_errorpage (outconvert, textout, logout,
1027 "The status action does not contain information\n"
1028 "about any receptionists. The method set_receptionist\n"
1029 "was probably not called from the module which instantiated\n"
1030 "this status action.\n");
1031 return true;
1032 }
1033
1034 // check to make sure status.dm was read in
1035 const recptconf &rcinfo = recpt->get_configinfo ();
1036 text_tset::const_iterator macrohere = rcinfo.macrofiles.begin ();
1037 text_tset::const_iterator macroend = rcinfo.macrofiles.end ();
1038 while (macrohere != macroend) {
1039 if (*macrohere == "status.dm") break;
1040 macrohere++;
1041 }
1042 if (macrohere == macroend) {
1043 output_errorpage (outconvert, textout, logout,
1044 "The status.dm file was not read in. This macro file is\n"
1045 "needed to display configuration and status information.\n");
1046 return true;
1047 }
1048
1049 // output the required status page
1050 text_t &arg_sp = args["sp"];
1051 if (arg_sp == "frameset") output_frameset (args, disp, outconvert, textout, logout);
1052 else if (arg_sp == "select") output_select (args, disp, outconvert, textout, logout);
1053 else if (arg_sp == "welcome") output_welcome (args, protos, disp, outconvert, textout, logout);
1054 else if (arg_sp == "generalinfo") output_generalinfo (args, disp, outconvert, textout, logout);
1055 else if (arg_sp == "argumentinfo") output_argumentinfo (args, disp, outconvert, textout, logout);
1056 else if (arg_sp == "actioninfo") output_actioninfo (args, disp, outconvert, textout, logout);
1057 else if (arg_sp == "browserinfo") output_browserinfo (args, disp, outconvert, textout, logout);
1058 else if (arg_sp == "protocolinfo") output_protocolinfo (args, disp, outconvert, textout, logout);
1059 else if (arg_sp == "collectioninfo") output_collectioninfo (args, disp, outconvert, textout, logout);
1060 else if (arg_sp == "initlog") output_initlog (args, disp, outconvert, textout, logout);
1061 else if (arg_sp == "errorlog") output_errorlog (args, disp, outconvert, textout, logout);
1062 else {
1063 output_errorpage (outconvert, textout, logout,
1064 "Unknown page \"" + arg_sp + "\".\n");
1065 }
1066
1067 return true;
1068}
1069
1070void statusaction::configure (const text_t &key, const text_tarray &cfgline) {
1071 if ((key == "status") && (cfgline.size() == 1) &&
1072 (cfgline[0] == "true" || cfgline[0] == "on" || cfgline[0] == "enabled")) {
1073 disabled = false;
1074 } else {
1075 // call the parent class to deal with the things which
1076 // are not dealt with here
1077 action::configure (key, cfgline);
1078 }
1079}
1080
Note: See TracBrowser for help on using the repository browser.