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

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

macrofiles is now a set to allow for multiple gsdlhomes

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