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

Last change on this file since 379 was 376, checked in by rjmcnab, 25 years ago

Added support for authenaction and usersaction

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 25.3 KB
Line 
1/**********************************************************************
2 *
3 * statusaction.cpp --
4 * Copyright (C) 1999 The New Zealand Digital Library Project
5 *
6 * PUT COPYRIGHT NOTICE HERE
7 *
8 * $Id: statusaction.cpp 376 1999-07-13 23:26:07Z rjmcnab $
9 *
10 *********************************************************************/
11
12/*
13 $Log$
14 Revision 1.14 1999/07/13 23:26:07 rjmcnab
15 Added support for authenaction and usersaction
16
17 Revision 1.13 1999/06/08 04:29:39 sjboddie
18 added argsinfo to the call to check_cgiargs to make it easy to set
19 args to their default if they're found to be screwed up
20
21 Revision 1.12 1999/04/06 22:20:35 rjmcnab
22 Got browsefilter working.
23
24 Revision 1.11 1999/03/31 23:44:49 rjmcnab
25 Altered the protocol so that the metadata is part of the filter.
26
27 Revision 1.10 1999/03/16 04:47:03 rjmcnab
28 Changed the list of arguments on the argument page to be the info list
29 not the current args list (there are some arguments which don't have
30 a default so they never make it onto the args list).
31
32 Revision 1.9 1999/03/11 01:26:02 rjmcnab
33 Fixed a few small formatting things.
34
35 Revision 1.8 1999/03/11 00:12:30 rjmcnab
36 Started using status.dm to handle the bulky text. Made the status
37 action use frames and added some more information.
38
39 Revision 1.7 1999/03/09 21:00:47 rjmcnab
40 Reorganised the statusaction, added more functions to comtypes.
41
42 Revision 1.6 1999/02/25 21:59:02 rjmcnab
43
44 Merged sources.
45
46 Revision 1.5 1999/02/21 22:33:58 rjmcnab
47
48 Lots of stuff :-)
49
50 Revision 1.4 1999/02/12 02:40:18 sjboddie
51
52 Added page action
53
54 Revision 1.3 1999/02/11 23:07:00 sjboddie
55
56 extended the status action
57
58 Revision 1.2 1999/02/11 01:24:06 rjmcnab
59
60 Fixed a few compiler warnings.
61
62 Revision 1.1 1999/02/11 01:01:27 rjmcnab
63
64 Initial revision.
65
66 */
67
68
69#include "statusaction.h"
70#include <assert.h>
71
72
73void statusaction::output_frameset (cgiargsclass &/*args*/, displayclass &disp,
74 outconvertclass &outconvert,
75 ostream &textout, ostream &/*logout*/) {
76 textout << outconvert << disp << "_status:frameset_\n";
77}
78
79void statusaction::output_select (cgiargsclass &/*args*/, displayclass &disp,
80 outconvertclass &outconvert,
81 ostream &textout, ostream &/*logout*/) {
82 textout << outconvert << disp << "_status:header_(selector)\n"
83 "_status:select_\n"
84 "_status:footer_\n";
85}
86
87void statusaction::output_generalinfo (cgiargsclass &/*args*/, displayclass &disp,
88 outconvertclass &outconvert,
89 ostream &textout, ostream &/*logout*/) {
90 if (recpt == NULL) return;
91 const recptconf &rcinfo = recpt->get_configinfo ();
92
93 textout << outconvert << disp << "_status:header_(General Information)\n";
94 textout << outconvert
95 << "<h2>General information</h2>\n"
96 << "<table>\n"
97 << "<tr valign=top><th>gsdlhome</th><td>\"" << rcinfo.gsdlhome
98 << "\"</td></tr>\n"
99 << "<tr valign=top><th>collection</th><td>\"" << rcinfo.collection
100 << "\"</td></tr>\n"
101 << "<tr valign=top><th>collectdir</th><td>\"" << rcinfo.collectdir
102 << "\"</td></tr>\n"
103 << "<tr valign=top><th>httpimg</th><td>\"" << rcinfo.httpimg
104 << "\"</td></tr>\n"
105 << "<tr valign=top><th>gwcgi</th><td>\"" << rcinfo.gwcgi
106 << "\"</td></tr>\n";
107
108 // macrofiles
109 textout << outconvert << "<tr valign=top><th>macrofiles</th><td>";
110 text_tarray::const_iterator macrohere = rcinfo.macrofiles.begin ();
111 text_tarray::const_iterator macroend = rcinfo.macrofiles.end ();
112 bool macrofirst = true;
113 while (macrohere != macroend) {
114 if (!macrofirst) textout << outconvert << ", ";
115 macrofirst = false;
116 textout << outconvert << "\"" << *macrohere << "\"";
117 macrohere++;
118 }
119 textout << outconvert << "</td></tr>\n";
120
121 // saveconf
122 textout << outconvert << "<tr valign=top><th>saveconf</th><td>\"" << rcinfo.saveconf
123 << "\"</td></tr>\n";
124
125 // arguments
126 cgiargsinfoclass *rcargsinfo = recpt->get_cgiargsinfo_ptr ();
127 if (rcargsinfo != NULL) {
128 textout << outconvert << "<tr valign=top><th>arguments</th><td>";
129
130 cgiargsinfoclass::const_iterator argsinfohere = rcargsinfo->begin ();
131 cgiargsinfoclass::const_iterator argsinfoend = rcargsinfo->end ();
132 bool argsinfofirst = true;
133 while (argsinfohere != argsinfoend) {
134 if (!argsinfofirst) textout << outconvert << ", ";
135 argsinfofirst = false;
136 textout << outconvert << "\"" << (*argsinfohere).second.shortname << "\"";
137 argsinfohere++;
138 }
139
140 textout << outconvert << "</td></tr>\n";
141 }
142
143 // actions
144 actionmapclass *actions = recpt->get_actionmap_ptr();
145 if (actions != NULL) {
146 textout << outconvert << "<tr valign=top><th>actions</th><td>";
147
148 actionptrmap::iterator actionshere = actions->begin ();
149 actionptrmap::iterator actionsend = actions->end ();
150 bool actionsfirst = true;
151 while (actionshere != actionsend) {
152 if (!actionsfirst) textout << outconvert << ", ";
153 actionsfirst = false;
154 assert ((*actionshere).second.a != NULL);
155 if ((*actionshere).second.a != NULL) {
156 textout << outconvert << "\"" << (*actionshere).second.a->get_action_name() << "\"";
157 }
158 actionshere++;
159 }
160
161 textout << outconvert << "</td></tr>\n";
162 }
163
164 // protocols
165 recptprotolistclass *protocols = recpt->get_recptprotolist_ptr ();
166 if (protocols != NULL) {
167 textout << outconvert << "<tr valign=top><th>protocols</th><td>";
168
169 recptprotolistclass::iterator protohere = protocols->begin ();
170 recptprotolistclass::iterator protoend = protocols->end ();
171 bool protofirst = true;
172 while (protohere != protoend) {
173 if (!protofirst) textout << outconvert << ", ";
174 protofirst = false;
175 if ((*protohere).p != NULL) {
176 textout << outconvert << "\"" << (*protohere).p->get_protocol_name() << "\"";
177 }
178 protohere++;
179 }
180
181 textout << outconvert << "</td></tr>\n";
182 }
183
184 // converters
185 convertinfoclass *converters = recpt->get_convertinfo_ptr ();
186 if (converters != NULL) {
187 textout << outconvert << "<tr valign=top><th>converters</th><td>";
188
189 convertinfoclass::iterator converthere = converters->begin ();
190 convertinfoclass::iterator convertend = converters->end ();
191 bool convertfirst = true;
192 while (converthere != convertend) {
193 if (!convertfirst) textout << outconvert << ", ";
194 convertfirst = false;
195 textout << outconvert << "\"" << (*converthere).second.name << "\"";
196 converthere++;
197 }
198
199 textout << outconvert << "</td></tr>\n";
200 }
201
202 textout << outconvert << disp << "</table>\n_status:footer_\n";
203}
204
205void statusaction::output_argumentinfo (cgiargsclass &args, displayclass &disp,
206 outconvertclass &outconvert,
207 ostream &textout, ostream &/*logout*/) {
208 if (recpt == NULL) return;
209 cgiargsinfoclass *rcargsinfo = recpt->get_cgiargsinfo_ptr ();
210 if (rcargsinfo == NULL) return;
211
212 textout << outconvert << disp << "_status:header_(Argument Information)\n";
213 textout << outconvert
214 << "<h2>Argument information</h2>\n"
215 << "<table>";
216
217 // argument information
218 textout << outconvert << "<tr valign=top><th>short name</th><th>long name</th>"
219 << "<th>multiple char?</th>"
220 << "<th>default</th><th>default status</th><th>saved args</th>"
221 << "<th>current value</th></tr>\n";
222
223
224 cgiargsinfoclass::const_iterator argsinfohere = rcargsinfo->begin();
225 cgiargsinfoclass::const_iterator argsinfoend = rcargsinfo->end();
226 text_t *arg_value;
227 while (argsinfohere != argsinfoend) {
228 const cgiarginfo &ainfo = (*argsinfohere).second;
229 textout << outconvert
230 << "<tr valign=top><td>" << ainfo.shortname << "</td>\n";
231
232 textout << outconvert << "<td>" << ainfo.longname << "</td>\n";
233 if (ainfo.multiplechar) textout << outconvert << "<td>yes</td>\n";
234 else textout << outconvert << "<td>no</td>\n";
235 textout << outconvert << "<td>" << ainfo.argdefault << "</td>\n";
236 switch (ainfo.defaultstatus) {
237 case cgiarginfo::none: textout << outconvert << "<td>none</td>\n"; break;
238 case cgiarginfo::weak: textout << outconvert << "<td>weak</td>\n"; break;
239 case cgiarginfo::good: textout << outconvert << "<td>good</td>\n"; break;
240 case cgiarginfo::config: textout << outconvert << "<td>config</td>\n"; break;
241 case cgiarginfo::imperative: textout << outconvert << "<td>imperative</td>\n"; break;
242 }
243 switch (ainfo.savedarginfo) {
244 case cgiarginfo::mustnot: textout << outconvert << "<td>mustnot</td>\n"; break;
245 case cgiarginfo::can: textout << outconvert << "<td>can</td>\n"; break;
246 case cgiarginfo::must: textout << outconvert << "<td>must</td>\n"; break;
247 }
248
249 arg_value = args.getarg (ainfo.shortname);
250 if (arg_value == NULL) textout << outconvert << "<td></td></tr>\n";
251 else textout << outconvert << "<td>\"" << *arg_value << "\"</td></tr>\n";
252
253 argsinfohere ++;
254 }
255
256 textout << outconvert << disp << "</table>\n_status:footer_\n";
257}
258
259void statusaction::output_actioninfo (cgiargsclass &/*args*/, displayclass &disp,
260 outconvertclass &outconvert,
261 ostream &textout, ostream &/*logout*/) {
262 if (recpt == NULL) return;
263 actionmapclass *actions = recpt->get_actionmap_ptr();
264
265 textout << outconvert << disp << "_status:header_(Action Information)\n";
266 textout << outconvert
267 << "<h2>Action information</h2>\n"
268 << "<table>";
269
270 // action information
271 if (actions != NULL) {
272 textout << outconvert
273 << "<tr><th>action name</th><th>cgi arguments</th></tr>\n";
274
275 actionptrmap::iterator actionshere = actions->begin ();
276 actionptrmap::iterator actionsend = actions->end ();
277 while (actionshere != actionsend) {
278 assert ((*actionshere).second.a != NULL);
279 if ((*actionshere).second.a != NULL) {
280 textout << outconvert
281 << "<tr><td>" << (*actionshere).second.a->get_action_name()
282 << "</td><td>";
283
284 cgiargsinfoclass argsinfo = (*actionshere).second.a->getargsinfo();
285 cgiargsinfoclass::const_iterator argsinfohere = argsinfo.begin ();
286 cgiargsinfoclass::const_iterator argsinfoend = argsinfo.end ();
287 bool aifirst = true;
288 while (argsinfohere != argsinfoend) {
289 if (!aifirst) textout << outconvert << ", ";
290 aifirst = false;
291 textout << outconvert << (*argsinfohere).second.shortname;
292 argsinfohere++;
293 }
294
295 textout << outconvert << "</td></tr>\n";
296 }
297 actionshere++;
298 }
299 }
300
301 textout << outconvert << disp << "</table>\n_status:footer_\n";
302}
303
304void statusaction::output_protocolinfo (cgiargsclass &/*args*/, displayclass &disp,
305 outconvertclass &outconvert,
306 ostream &textout, ostream &logout) {
307 if (recpt == NULL) return;
308 const recptconf &rcinfo = recpt->get_configinfo ();
309 bool colspecific = !rcinfo.collection.empty();
310 bool unreachablecol = false;
311
312 recptprotolistclass *rprotolist = recpt->get_recptprotolist_ptr ();
313 if (rprotolist == NULL) return;
314
315 textout << outconvert << disp << "_status:header_(Protocol Information)\n";
316 textout << outconvert
317 << "<h2>Protocol information</h2>\n"
318 << "<table>\n"
319 << "<tr><th>protocol</th><th>collections</th></tr>\n";
320
321 text_t protoname;
322 recptprotolistclass::iterator rprotolist_here = rprotolist->begin();
323 recptprotolistclass::iterator rprotolist_end = rprotolist->end();
324 while (rprotolist_here != rprotolist_end) {
325 if ((*rprotolist_here).p != NULL) {
326 protoname = (*rprotolist_here).p->get_protocol_name();
327 textout << outconvert
328 << "<tr><td>"
329 << protoname
330 << "</td><td>";
331
332 text_tarray collist;
333 comerror_t err;
334 (*rprotolist_here).p->get_collection_list (collist, err, logout);
335 if (err == noError) {
336 text_tarray::iterator collist_here = collist.begin();
337 text_tarray::iterator collist_end = collist.end();
338 bool first = true;
339 while (collist_here != collist_end) {
340 if (!first) textout << outconvert << ", ";
341 first = false;
342
343 if (colspecific && *collist_here != rcinfo.collection) {
344 unreachablecol = true;
345 textout << outconvert << "\"" << *collist_here << "\"";
346 } else {
347 textout << outconvert << disp
348 << "\"<a href=\"_gwcgi_?e=_compressedoptions_&a=status&sp=collectioninfo&pr="
349 << protoname
350 << "&c="
351 << *collist_here
352 << "\">"
353 << *collist_here
354 << "</a>\"";
355 }
356
357 collist_here++;
358 }
359
360 } else {
361 textout << outconvert << "Error (" << get_comerror_string (err)
362 << ") while getting collect list\n";
363 }
364
365 textout << outconvert
366 << "</td></tr>\n";
367 }
368
369 rprotolist_here++;
370 }
371
372 textout << outconvert << "</table>\n";
373 if (unreachablecol) {
374 textout << outconvert
375 << "<b>Warning:</b> the receptionist is running in collection specific\n"
376 << "mode making some of the collections unreachable.\n";
377 }
378 textout << outconvert << disp << "_status:footer_\n";
379}
380
381void statusaction::output_collectioninfo (cgiargsclass &args, displayclass &disp,
382 outconvertclass &outconvert,
383 ostream &textout, ostream &logout) {
384 if (recpt == NULL) return;
385
386 textout << outconvert << disp << "_status:header_(Collection info)\n";
387 textout << outconvert << "<h2>Collection info</h2>\n";
388
389 // get the list of protocols
390 recptprotolistclass *rprotolist = recpt->get_recptprotolist_ptr ();
391 if (rprotolist == NULL) return;
392
393 // look for the desired protocol
394 text_t &arg_pr = args["pr"];
395 text_t &arg_c = args["c"];
396 recptproto *rproto;
397 recptprotolistclass::iterator rprotolist_here = rprotolist->begin();
398 recptprotolistclass::iterator rprotolist_end = rprotolist->end();
399 while (rprotolist_here != rprotolist_end) {
400 rproto = (*rprotolist_here).p;
401 if (rproto != NULL && rproto->get_protocol_name() == arg_pr) {
402 // see if the protocol has the collection
403 bool hascollection;
404 comerror_t err;
405 rproto->has_collection (arg_c, hascollection, err, logout);
406 if (err == noError && hascollection) break;
407 }
408 rprotolist_here++;
409 }
410
411 if (rprotolist_here == rprotolist_end) {
412 textout << outconvert << "Protocol \"" << arg_pr << "\" with collection \""
413 << arg_c << "\" was not found\n";
414
415 } else {
416 ColInfoResponse_t collectinfo;
417 comerror_t err;
418
419 rproto->get_collectinfo (arg_c, collectinfo, err, logout);
420 if (err == noError) {
421 textout << outconvert << "<table>\n"
422 << "<tr><th>collection name</th><td>\""
423 << collectinfo.shortInfo.name
424 << "\"</td></tr>\n"
425
426 << "<tr><th>host</th><td>\""
427 << collectinfo.shortInfo.host
428 << "\"</td></tr>\n"
429
430 << "<tr><th>port</th><td>\""
431 << collectinfo.shortInfo.port
432 << "\"</td></tr>\n"
433
434 << "<tr><th>is public?</th><td>";
435 if (collectinfo.isPublic) textout << outconvert << "true";
436 else textout << outconvert << "false";
437 textout << outconvert
438 << "</td></tr>\n"
439
440 << "<tr><th>is beta?</th><td>";
441 if (collectinfo.isBeta) textout << outconvert << "true";
442 else textout << outconvert << "false";
443 textout << outconvert
444 << "</td></tr>\n"
445
446 << "<tr><th>build date</th><td>\""
447 << collectinfo.buildDate
448 << "\"</td></tr>\n"
449
450 << "<tr><th>interface languages</th><td>";
451 text_tarray::iterator languages_here = collectinfo.languages.begin();
452 text_tarray::iterator languages_end = collectinfo.languages.end();
453 bool languages_first = true;
454 while (languages_here != languages_end) {
455 if (!languages_first) textout << outconvert << ", ";
456 languages_first = false;
457 textout << outconvert << "\"" << *languages_here << "\"";
458 languages_here++;
459 }
460 textout << outconvert
461 << "</td></tr>\n"
462
463 << "<tr><th>number of documents</th><td>\""
464 << collectinfo.numDocs
465 << "\"</td></tr>\n"
466
467 << "<tr><th>number of words</th><td>\""
468 << collectinfo.numWords
469 << "\"</td></tr>\n"
470
471 << "<tr><th>number of bytes</th><td>\""
472 << collectinfo.numBytes
473 << "\"</td></tr>\n"
474
475 << "</table>";
476
477 } else {
478 textout << outconvert << "Error (" << get_comerror_string (err)
479 << ") while getting collect information\n";
480 }
481
482
483 InfoFiltersResponse_t filterinfo;
484 InfoFilterOptionsRequest_t filteroptions_request;
485 InfoFilterOptionsResponse_t filteroptions;
486 rproto->get_filterinfo (arg_c, filterinfo, err, logout);
487 if (err == noError) {
488 text_tset::iterator filternames_here = filterinfo.filterNames.begin();
489 text_tset::iterator filternames_end = filterinfo.filterNames.end();
490 while (filternames_here != filternames_end) {
491 textout << outconvert
492 << "<hr>\n"
493 << "<h3>Filter options for \"" << (*filternames_here) << "\"</h3>\n"
494 << "<table>\n"
495 << "<tr><th>option name</th><th>type</th><th>repeatable</th>"
496 << "<th>default value</th><th>valid values</th></tr>\n";
497
498 filteroptions_request.clear();
499 filteroptions_request.filterName = *filternames_here;
500 rproto->get_filteroptions (arg_c, filteroptions_request,
501 filteroptions, err, logout);
502 if (err == noError) {
503 FilterOption_tmap::iterator filteropt_here =
504 filteroptions.filterOptions.begin();
505 FilterOption_tmap::iterator filteropt_end =
506 filteroptions.filterOptions.end();
507 while (filteropt_here != filteropt_end) {
508 textout << outconvert
509 << "<tr><td>\""
510 << (*filteropt_here).second.name
511 << "\"</td>\n"
512
513 << "<td>";
514 text_t type_string;
515 switch ((*filteropt_here).second.type) {
516 case FilterOption_t::booleant: type_string = "boolean"; break;
517 case FilterOption_t::integert: type_string = "integer"; break;
518 case FilterOption_t::enumeratedt: type_string = "enumerated"; break;
519 case FilterOption_t::stringt: type_string = "string"; break;
520 }
521 textout << outconvert
522 << type_string
523 << "</td>\n"
524
525 << "<td>";
526 text_t repeat_string;
527 switch ((*filteropt_here).second.repeatable) {
528 case FilterOption_t::onePerQuery: repeat_string = "one per query"; break;
529 case FilterOption_t::onePerTerm: repeat_string = "one per term"; break;
530 case FilterOption_t::nPerTerm: repeat_string = "n per term"; break;
531 }
532 textout << outconvert
533 << repeat_string
534 << "</td>\n"
535
536 << "<td>\""
537 << (*filteropt_here).second.defaultValue
538 << "\"</td>\n"
539
540 << "<td>";
541
542 text_tarray::iterator valid_here =
543 (*filteropt_here).second.validValues.begin();
544 text_tarray::iterator valid_end =
545 (*filteropt_here).second.validValues.end();
546 bool valid_first = true;
547 while (valid_here != valid_end) {
548 if (!valid_first) textout << outconvert << ", ";
549 valid_first = false;
550 textout << outconvert << "\"" << *valid_here << "\"";
551 valid_here++;
552 }
553 textout << outconvert
554 << "</td></tr>\n";
555
556 filteropt_here++;
557 }
558
559 textout << outconvert
560 << "</table>\n";
561
562 } else {
563 textout << outconvert << "Error (" << get_comerror_string (err)
564 << ") while getting filter option information\n";
565 }
566
567 filternames_here++;
568 }
569
570 } else {
571 textout << outconvert << "Error (" << get_comerror_string (err)
572 << ") while getting filter information\n";
573 }
574 }
575
576 textout << outconvert << disp << "_status:footer_\n";
577}
578
579void statusaction::output_initlog (cgiargsclass &/*args*/, displayclass &disp,
580 outconvertclass &outconvert,
581 ostream &textout, ostream &/*logout*/) {
582 textout << outconvert << disp << "_status:header_(Init log)\n";
583 textout << outconvert << "<h2>Init log</h2>\n";
584
585 ifstream initin (GSDL_GSDLHOME "/etc/initout.txt");
586 if (initin) {
587 textout << outconvert << "<p>The initialisation error log, "
588 GSDL_GSDLHOME "/etc/initout.txt, contains the\n";
589 textout << outconvert << "following information:\n\n";
590 text_t errorpage = "<p><pre>\n";
591
592 char c;
593 initin.get(c);
594 while (!initin.eof ()) {
595 errorpage.push_back(c);
596 initin.get(c);
597 }
598
599 errorpage += "</pre>\n";
600 initin.close();
601 textout << outconvert << errorpage;
602
603 } else {
604 textout << outconvert << "Couldn't read initialisation error log, " GSDL_GSDLHOME "/etc/initout.txt.\n";
605 }
606
607 textout << outconvert << disp << "_status:footer_\n";
608}
609
610void statusaction::output_errorlog (cgiargsclass &/*args*/, displayclass &disp,
611 outconvertclass &outconvert,
612 ostream &textout, ostream &logout) {
613 textout << outconvert << disp << "_status:header_(Error log)\n";
614 textout << outconvert << "<h2>Error log</h2>\n";
615 logout << flush;
616
617 ifstream errin (GSDL_GSDLHOME "/etc/errout.txt");
618 if (errin) {
619 textout << outconvert << "<p>The error log, " GSDL_GSDLHOME "/etc/errout.txt, contains the\n";
620 textout << outconvert << "following information:\n\n";
621 text_t errorpage = "<p><pre>\n";
622
623 char c;
624 errin.get(c);
625 while (!errin.eof ()) {
626 errorpage.push_back(c);
627 errin.get(c);
628 }
629
630 errorpage += "</pre>\n";
631 errin.close();
632 textout << outconvert << errorpage;
633
634 } else {
635 textout << outconvert << "Couldn't read error log, " GSDL_GSDLHOME "/etc/errout.txt.\n";
636 }
637
638 textout << outconvert << disp << "_status:footer_\n";
639}
640
641void statusaction::output_errorpage (outconvertclass &outconvert,
642 ostream &textout, ostream &/*logout*/,
643 text_t message) {
644 textout << outconvert
645 << "<html>\n"
646 << "<head>\n"
647 << "<title>Error</title>\n"
648 << "</head>\n"
649 << "<body bgcolor=\"#ffffff\" text=\"#000000\" link=\"#006666\" "
650 << "alink=\"#cc9900\" vlink=\"#666633\">\n"
651 << "<h2>Oops!</h2>\n"
652 << message
653 << "\n</body>\n"
654 << "</html>\n";
655 return;
656}
657
658
659
660statusaction::statusaction () {
661 disabled = true;
662 recpt = NULL;
663
664 // this action uses cgi variable "a"
665 cgiarginfo arg_ainfo;
666 arg_ainfo.shortname = "a";
667 arg_ainfo.longname = "action";
668 arg_ainfo.multiplechar = true;
669 arg_ainfo.defaultstatus = cgiarginfo::weak;
670 arg_ainfo.argdefault = "status";
671 arg_ainfo.savedarginfo = cgiarginfo::must;
672 argsinfo.addarginfo (NULL, arg_ainfo);
673
674 // "sp" -- status page
675 arg_ainfo.shortname = "sp";
676 arg_ainfo.longname = "status page";
677 arg_ainfo.multiplechar = true;
678 arg_ainfo.defaultstatus = cgiarginfo::good;
679 arg_ainfo.argdefault = "frameset";
680 arg_ainfo.savedarginfo = cgiarginfo::can;
681 argsinfo.addarginfo (NULL, arg_ainfo);
682
683 // "pr" -- protocol
684 arg_ainfo.shortname = "pr";
685 arg_ainfo.longname = "protocol";
686 arg_ainfo.multiplechar = true;
687 arg_ainfo.defaultstatus = cgiarginfo::none;
688 arg_ainfo.argdefault = "";
689 arg_ainfo.savedarginfo = cgiarginfo::can;
690 argsinfo.addarginfo (NULL, arg_ainfo);
691}
692
693statusaction::~statusaction () {
694}
695
696bool statusaction::check_cgiargs (cgiargsinfoclass &/*argsinfo*/, cgiargsclass &args,
697 ostream &/*logout*/) {
698 // authenticate the user if authentication is avaiable
699 args["uan"] = 1;
700 args["ug"] = "administrator";
701
702 return true;
703}
704
705void statusaction::get_cgihead_info (cgiargsclass &/*args*/, response_t &response,
706 text_t &response_data, ostream &/*logout*/) {
707 response = content;
708 response_data = "text/html";
709}
710
711bool statusaction::do_action (cgiargsclass &args, recptproto */*collectproto*/,
712 displayclass &disp, outconvertclass &outconvert,
713 ostream &textout, ostream &logout) {
714 // make sure the status function is enabled
715 if (disabled) {
716 output_errorpage (outconvert, textout, logout,
717 "The status action is disabled. "
718 "See the documentation (what documentation!) on how "
719 "to enable it.");
720 return true;
721 }
722
723 // make sure we know about a receptionist
724 if (recpt == NULL) {
725 output_errorpage (outconvert, textout, logout,
726 "The status action does not contain information\n"
727 "about any receptionists. The method set_receptionist\n"
728 "was probably not called from the module which instantiated\n"
729 "this status action.\n");
730 return true;
731 }
732
733 // check to make sure status.dm was read in
734 const recptconf &rcinfo = recpt->get_configinfo ();
735 text_tarray::const_iterator macrohere = rcinfo.macrofiles.begin ();
736 text_tarray::const_iterator macroend = rcinfo.macrofiles.end ();
737 while (macrohere != macroend) {
738 if (*macrohere == "status.dm") break;
739 macrohere++;
740 }
741 if (macrohere == macroend) {
742 output_errorpage (outconvert, textout, logout,
743 "The status.dm file was not read in. This macro file is\n"
744 "needed to display configuration and status information.\n");
745 return true;
746 }
747
748 // output the required status page
749 text_t &arg_sp = args["sp"];
750 if (arg_sp == "frameset") output_frameset (args, disp, outconvert, textout, logout);
751 else if (arg_sp == "select") output_select (args, disp, outconvert, textout, logout);
752 else if (arg_sp == "generalinfo") output_generalinfo (args, disp, outconvert, textout, logout);
753 else if (arg_sp == "argumentinfo") output_argumentinfo (args, disp, outconvert, textout, logout);
754 else if (arg_sp == "actioninfo") output_actioninfo (args, disp, outconvert, textout, logout);
755 else if (arg_sp == "protocolinfo") output_protocolinfo (args, disp, outconvert, textout, logout);
756 else if (arg_sp == "collectioninfo") output_collectioninfo (args, disp, outconvert, textout, logout);
757 else if (arg_sp == "initlog") output_initlog (args, disp, outconvert, textout, logout);
758 else if (arg_sp == "errorlog") output_errorlog (args, disp, outconvert, textout, logout);
759 else {
760 output_errorpage (outconvert, textout, logout,
761 "Unknown page \"" + arg_sp + "\".\n");
762 }
763
764 return true;
765}
766
767void statusaction::configure (const text_t &key, const text_tarray &cfgline) {
768 if ((key == "status") && (cfgline.size() == 1) &&
769 (cfgline[0] == "true" || cfgline[0] == "on" || cfgline[0] == "enabled")) {
770 disabled = false;
771 } else {
772 // call the parent class to deal with the things which
773 // are not dealt with here
774 action::configure (key, cfgline);
775 }
776}
777
Note: See TracBrowser for help on using the repository browser.