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

Last change on this file since 995 was 995, checked in by sjboddie, 24 years ago

fixed some compiler warnings

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