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

Last change on this file since 793 was 777, checked in by sjboddie, 25 years ago

added some new(ish) options

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