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

Last change on this file since 727 was 722, checked in by davidb, 25 years ago

Collection building support through web pages
and internal and external link handling for collection documents

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