source: branches/z3950-branch/gsdl/src/recpt/statusaction.cpp@ 1342

Last change on this file since 1342 was 1342, checked in by johnmcp, 24 years ago

Relatively stable z39.50 implementation now, merged with the mgpp source.
(Still needs a decent interface and query language though...)

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 32.6 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 *********************************************************************/
25
26#include "statusaction.h"
27#include "fileutil.h"
28#include "htmlutils.h"
29#include <assert.h>
30
31
32void statusaction::output_frameset (cgiargsclass &/*args*/, displayclass &disp,
33 outconvertclass &outconvert,
34 ostream &textout, ostream &/*logout*/) {
35 textout << outconvert << disp << "_status:frameset_\n";
36}
37
38void statusaction::output_select (cgiargsclass &/*args*/, displayclass &disp,
39 outconvertclass &outconvert,
40 ostream &textout, ostream &/*logout*/) {
41 textout << outconvert << disp << "_status:header_(selector)\n"
42 "_status:select_\n"
43 "_status:footer_\n";
44}
45
46void statusaction::output_welcome (cgiargsclass &/*args*/, recptprotolistclass *protos,
47 displayclass &disp, outconvertclass &outconvert,
48 ostream &textout, ostream &logout) {
49
50 if (recpt == NULL) return;
51
52 textout << outconvert << disp
53 << "_status:infoheader_(_titlewelcome_)\n"
54 << "_status:welcome_"
55 << "<center><table width=_pagewidth_>\n"
56 << "<th align=left>abbrev.</th><th align=left>collection</th>"
57 << "<th align=left>public?</th><th align=left>running?</th></tr>\n";
58
59 recptprotolistclass::iterator rprotolist_here = protos->begin();
60 recptprotolistclass::iterator rprotolist_end = protos->end();
61 while (rprotolist_here != rprotolist_end) {
62 if ((*rprotolist_here).p != NULL) {
63 text_t protoname = (*rprotolist_here).p->get_protocol_name();
64 text_tarray collist;
65 comerror_t err;
66 (*rprotolist_here).p->get_collection_list (collist, err, logout);
67 if (err == noError) {
68 text_tarray::iterator collist_here = collist.begin();
69 text_tarray::iterator collist_end = collist.end();
70
71 while (collist_here != collist_end) {
72
73 textout << outconvert << disp
74 << "<tr><td><a href=\"_gwcgi_?e=_compressedoptions_&a=status&sp=collectioninfo&pr="
75 << protoname
76 << "&c="
77 << *collist_here
78 << "\">"
79 << *collist_here
80 << "</a></td>";
81
82 ColInfoResponse_t *cinfo = recpt->get_collectinfo_ptr ((*rprotolist_here).p, *collist_here, logout);
83 if (cinfo != NULL) {
84 text_t collname = *collist_here;
85 text_tmap::iterator it = cinfo->collectionmeta.find("collectionname");
86 if (it != cinfo->collectionmeta.end()) collname = (*it).second;
87
88 textout << "<td>";
89 if (cinfo->buildDate > 0)
90 textout << outconvert << disp
91 << "<a href=\"_httppagex_(about)&c=" << *collist_here
92 << "\" target=\\_top>";
93
94 textout << outconvert << disp << collname;
95
96 if (cinfo->buildDate > 0) textout << "</a>";
97
98 textout << "</td>";
99
100 if (cinfo->isPublic) textout << "<td>yes</td>";
101 else textout << "<td>no</td>";
102
103 if (cinfo->buildDate > 0)
104 textout << outconvert << "<td>yes</td>";
105 else
106 textout << "<td>no</td>";
107
108 } else {
109 textout << "<td></td><td></td><td></td>";
110 }
111
112 textout << "</tr>\n";
113 collist_here ++;
114 }
115 }
116 }
117 rprotolist_here ++;
118 }
119
120 textout << "</table></center>\n";
121 textout << outconvert << disp << "_status:infofooter_\n";
122}
123
124void statusaction::output_generalinfo (cgiargsclass &/*args*/, displayclass &disp,
125 outconvertclass &outconvert,
126 ostream &textout, ostream &/*logout*/) {
127 if (recpt == NULL) return;
128 const recptconf &rcinfo = recpt->get_configinfo ();
129
130 textout << outconvert << disp << "_status:infoheader_(General Information)\n";
131 textout << outconvert
132 << "<h2>General information</h2>\n"
133 << "<table>\n"
134 << "<tr valign=top><th>gsdlhome</th><td>\"" << rcinfo.gsdlhome
135 << "\"</td></tr>\n"
136 << "<tr valign=top><th>collection</th><td>\"" << rcinfo.collection
137 << "\"</td></tr>\n"
138 << "<tr valign=top><th>collectdir</th><td>\"" << rcinfo.collectdir
139 << "\"</td></tr>\n"
140 << "<tr valign=top><th>httpprefix</th><td>\"" << rcinfo.httpprefix
141 << "\"</td></tr>\n"
142 << "<tr valign=top><th>httpimg</th><td>\"" << rcinfo.httpimg
143 << "\"</td></tr>\n"
144 << "<tr valign=top><th>gwcgi</th><td>\"" << rcinfo.gwcgi
145 << "\"</td></tr>\n";
146
147 // macrofiles
148 textout << outconvert << "<tr valign=top><th>macrofiles</th><td>";
149 text_tset::const_iterator macrohere = rcinfo.macrofiles.begin ();
150 text_tset::const_iterator macroend = rcinfo.macrofiles.end ();
151 bool macrofirst = true;
152 while (macrohere != macroend) {
153 if (!macrofirst) textout << outconvert << ", ";
154 macrofirst = false;
155 textout << outconvert << "\"" << *macrohere << "\"";
156 macrohere++;
157 }
158 textout << outconvert << "</td></tr>\n";
159
160 // saveconf
161 textout << outconvert << "<tr valign=top><th>saveconf</th><td>\"" << rcinfo.saveconf
162 << "\"</td></tr>\n";
163
164 // usecookies
165 textout << outconvert << "<tr valign=top><th>usecookies</th><td>\"";
166 if (rcinfo.usecookies) textout << outconvert << "true";
167 else textout << outconvert << "false";
168 textout << outconvert << "\"</td></tr>\n";
169
170 // logcgiargs
171 textout << outconvert << "<tr valign=top><th>logcgiargs</th><td>\"";
172 if (rcinfo.logcgiargs) textout << outconvert << "true";
173 else textout << outconvert << "false";
174 textout << outconvert << "\"</td></tr>\n";
175
176 // pageparams
177 textout << outconvert << "<tr valign=top><th>pageparams</th><td>";
178 text_tmap::const_iterator params_here = rcinfo.pageparams.begin();
179 text_tmap::const_iterator params_end = rcinfo.pageparams.end();
180 bool params_first = true;
181 while (params_here != params_end) {
182 if (!params_first) textout << outconvert << ", ";
183 params_first = false;
184 textout << outconvert << "\"" << (*params_here).first << "\" != \""
185 << (*params_here).second << "\"";
186
187 params_here++;
188 }
189 textout << outconvert << "</td></tr>\n";
190
191 // macroprecedence
192 textout << outconvert << "<tr valign=top><th>macroprecedence</th><td>\"" << rcinfo.macroprecedence
193 << "\"</td></tr>\n";
194
195 // arguments
196 cgiargsinfoclass *rcargsinfo = recpt->get_cgiargsinfo_ptr ();
197 if (rcargsinfo != NULL) {
198 textout << outconvert << "<tr valign=top><th>arguments</th><td>";
199
200 cgiargsinfoclass::const_iterator argsinfohere = rcargsinfo->begin ();
201 cgiargsinfoclass::const_iterator argsinfoend = rcargsinfo->end ();
202 bool argsinfofirst = true;
203 while (argsinfohere != argsinfoend) {
204 if (!argsinfofirst) textout << outconvert << ", ";
205 argsinfofirst = false;
206 textout << outconvert << "\"" << (*argsinfohere).second.shortname << "\"";
207 argsinfohere++;
208 }
209
210 textout << outconvert << "</td></tr>\n";
211 }
212
213 // actions
214 actionmapclass *actions = recpt->get_actionmap_ptr();
215 if (actions != NULL) {
216 textout << outconvert << "<tr valign=top><th>actions</th><td>";
217
218 actionptrmap::iterator actionshere = actions->begin ();
219 actionptrmap::iterator actionsend = actions->end ();
220 bool actionsfirst = true;
221 while (actionshere != actionsend) {
222 if (!actionsfirst) textout << outconvert << ", ";
223 actionsfirst = false;
224 assert ((*actionshere).second.a != NULL);
225 if ((*actionshere).second.a != NULL) {
226 textout << outconvert << "\"" << (*actionshere).second.a->get_action_name() << "\"";
227 }
228 actionshere++;
229 }
230
231 textout << outconvert << "</td></tr>\n";
232 }
233
234 // browsers
235 browsermapclass *browsers = recpt->get_browsermap_ptr();
236 if (browsers != NULL) {
237 textout << outconvert << "<tr valign=top><th>browsers</th><td>";
238
239 browserptrmap::iterator browsershere = browsers->begin ();
240 browserptrmap::iterator browsersend = browsers->end ();
241 bool browsersfirst = true;
242 while (browsershere != browsersend) {
243 if (!browsersfirst) textout << outconvert << ", ";
244 browsersfirst = false;
245 assert ((*browsershere).second.b != NULL);
246 if ((*browsershere).second.b != NULL) {
247 textout << outconvert << "\"" << (*browsershere).second.b->get_browser_name() << "\"";
248 }
249 browsershere++;
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_browserinfo (cgiargsclass &/*args*/, displayclass &disp,
399 outconvertclass &outconvert,
400 ostream &textout, ostream &/*logout*/) {
401 if (recpt == NULL) return;
402 browsermapclass *browsers = recpt->get_browsermap_ptr();
403
404 textout << outconvert << disp << "_status:infoheader_(Browser Information)\n";
405 textout << outconvert
406 << "<h2>Browser information</h2>\n"
407 << "<table>";
408
409 // browser information
410 if (browsers != NULL) {
411 textout << outconvert
412 << "<tr><th>browser name</th><th>default formatstring</th></tr>\n";
413
414 browserptrmap::iterator browsershere = browsers->begin ();
415 browserptrmap::iterator browsersend = browsers->end ();
416 while (browsershere != browsersend) {
417 assert ((*browsershere).second.b != NULL);
418 if ((*browsershere).second.b != NULL) {
419 textout << outconvert
420 << "<tr><td>" << (*browsershere).second.b->get_browser_name()
421 << "</td><td>" << html_safe ((*browsershere).second.b->get_default_formatstring())
422 << "</td></tr>\n";
423 }
424 browsershere++;
425 }
426 }
427
428 textout << outconvert << disp << "</table>\n_status:infofooter_\n";
429}
430
431void statusaction::output_protocolinfo (cgiargsclass &/*args*/, displayclass &disp,
432 outconvertclass &outconvert,
433 ostream &textout, ostream &logout) {
434 if (recpt == NULL) return;
435 const recptconf &rcinfo = recpt->get_configinfo ();
436 bool colspecific = !rcinfo.collection.empty();
437 bool unreachablecol = false;
438
439 recptprotolistclass *rprotolist = recpt->get_recptprotolist_ptr ();
440 if (rprotolist == NULL) return;
441
442 textout << outconvert << disp << "_status:infoheader_(Protocol Information)\n";
443 textout << outconvert
444 << "<h2>Protocol information</h2>\n"
445 << "<table>\n"
446 << "<tr><th>protocol</th><th>collections</th></tr>\n";
447
448 text_t protoname;
449 recptprotolistclass::iterator rprotolist_here = rprotolist->begin();
450 recptprotolistclass::iterator rprotolist_end = rprotolist->end();
451 while (rprotolist_here != rprotolist_end) {
452 if ((*rprotolist_here).p != NULL) {
453 protoname = (*rprotolist_here).p->get_protocol_name();
454 textout << outconvert
455 << "<tr><td>"
456 << protoname
457 << "</td><td>";
458
459 text_tarray collist;
460 comerror_t err;
461 (*rprotolist_here).p->get_collection_list (collist, err, logout);
462 if (err == noError) {
463 text_tarray::iterator collist_here = collist.begin();
464 text_tarray::iterator collist_end = collist.end();
465 bool first = true;
466 while (collist_here != collist_end) {
467 if (!first) textout << outconvert << ", ";
468 first = false;
469
470 if (colspecific && *collist_here != rcinfo.collection) {
471 unreachablecol = true;
472 textout << outconvert << "\"" << *collist_here << "\"";
473 } else {
474 textout << outconvert << disp
475 << "\"<a href=\"_gwcgi_?e=_compressedoptions_&a=status&sp=collectioninfo&pr="
476 << protoname
477 << "&c="
478 << *collist_here
479 << "\">"
480 << *collist_here
481 << "</a>\"";
482 }
483
484 collist_here++;
485 }
486
487 } else {
488 textout << outconvert << "Error (" << get_comerror_string (err)
489 << ") while getting collect list\n";
490 }
491
492 textout << outconvert
493 << "</td></tr>\n";
494 }
495
496 rprotolist_here++;
497 }
498
499 textout << outconvert << "</table>\n";
500 if (unreachablecol) {
501 textout << outconvert
502 << "<b>Warning:</b> the receptionist is running in collection specific\n"
503 << "mode making some of the collections unreachable.\n";
504 }
505 textout << outconvert << disp << "_status:infofooter_\n";
506}
507
508void statusaction::output_collectioninfo (cgiargsclass &args, displayclass &disp,
509 outconvertclass &outconvert,
510 ostream &textout, ostream &logout) {
511 if (recpt == NULL) return;
512
513 textout << outconvert << disp << "_status:infoheader_(Collection info)\n";
514 textout << outconvert << "<h2>Collection info</h2>\n";
515
516 // get the list of protocols
517 recptprotolistclass *rprotolist = recpt->get_recptprotolist_ptr ();
518 if (rprotolist == NULL) return;
519
520 // look for the desired protocol
521 text_t &arg_pr = args["pr"];
522 text_t &arg_c = args["c"];
523 recptproto *rproto = NULL;
524 recptprotolistclass::iterator rprotolist_here = rprotolist->begin();
525 recptprotolistclass::iterator rprotolist_end = rprotolist->end();
526 while (rprotolist_here != rprotolist_end) {
527 rproto = (*rprotolist_here).p;
528 if (rproto != NULL && rproto->get_protocol_name() == arg_pr) {
529 // see if the protocol has the collection
530 bool hascollection;
531 comerror_t err;
532 rproto->has_collection (arg_c, hascollection, err, logout);
533 if (err == noError && hascollection) break;
534 }
535 rprotolist_here++;
536 }
537
538 if (rprotolist_here == rprotolist_end) {
539 textout << outconvert << "Protocol \"" << arg_pr << "\" with collection \""
540 << arg_c << "\" was not found\n";
541
542 } else {
543 // rproto can't be NULL to get here
544 ColInfoResponse_t *collectinfo = recpt->get_collectinfo_ptr (rproto, arg_c, logout);
545 if (collectinfo != NULL) {
546 textout << outconvert << "<table>\n"
547 << "<tr><th>collection name</th><td>\""
548 << collectinfo->shortInfo.name
549 << "\"</td></tr>\n"
550
551 << "<tr><th>host</th><td>\""
552 << collectinfo->shortInfo.host
553 << "\"</td></tr>\n"
554
555 << "<tr><th>port</th><td>\""
556 << collectinfo->shortInfo.port
557 << "\"</td></tr>\n"
558
559 << "<tr><th>is public?</th><td>";
560 if (collectinfo->isPublic) textout << outconvert << "true";
561 else textout << outconvert << "false";
562 textout << outconvert
563 << "</td></tr>\n"
564
565 << "<tr><th>is beta?</th><td>";
566 if (collectinfo->isBeta) textout << outconvert << "true";
567 else textout << outconvert << "false";
568 textout << outconvert
569 << "</td></tr>\n"
570
571 << "<tr><th>build date</th><td>\""
572 << collectinfo->buildDate
573 << "\"</td></tr>\n"
574
575 << "<tr><th>interface languages</th><td>";
576 text_tarray::iterator languages_here = collectinfo->languages.begin();
577 text_tarray::iterator languages_end = collectinfo->languages.end();
578 bool languages_first = true;
579 while (languages_here != languages_end) {
580 if (!languages_first) textout << outconvert << ", ";
581 languages_first = false;
582 textout << outconvert << "\"" << *languages_here << "\"";
583 languages_here++;
584 }
585
586 textout << "<tr><th valign=top>collection metadata</th><td><table>\n";
587 text_tmap::iterator meta_here = collectinfo->collectionmeta.begin();
588 text_tmap::iterator meta_end = collectinfo->collectionmeta.end();
589 while (meta_here != meta_end) {
590 textout << outconvert << "<tr><td>" << (*meta_here).first
591 << "</td><td>" << (*meta_here).second << "</td></tr>\n";
592 meta_here ++;
593 }
594 textout << "</table></td></tr>\n";
595
596 textout << "<tr><th valign=top>format info</th><td><table>\n";
597 text_tmap::iterator format_here = collectinfo->format.begin();
598 text_tmap::iterator format_end = collectinfo->format.end();
599 while (format_here != format_end) {
600 textout << outconvert << "<tr><td>" << (*format_here).first
601 << "</td><td>" << html_safe((*format_here).second) << "</td></tr>\n";
602 format_here ++;
603 }
604 textout << "</table></td></tr>\n";
605
606 textout << "<tr><th valign=top>building info</th><td><table>\n";
607 text_tmap::iterator building_here = collectinfo->building.begin();
608 text_tmap::iterator building_end = collectinfo->building.end();
609 while (building_here != building_end) {
610 textout << outconvert << "<tr><td>" << (*building_here).first
611 << "</td><td>" << (*building_here).second << "</td></tr>\n";
612 building_here ++;
613 }
614 textout << "</table></td></tr>\n";
615
616 textout << outconvert
617 << "</td></tr>\n"
618
619 << "<tr><th>number of documents</th><td>\""
620 << collectinfo->numDocs
621 << "\"</td></tr>\n"
622
623 << "<tr><th>number of sections</th><td>\""
624 << collectinfo->numSections
625 << "\"</td></tr>\n"
626
627 << "<tr><th>number of words</th><td>\""
628 << collectinfo->numWords
629 << "\"</td></tr>\n"
630
631 << "<tr><th>number of bytes</th><td>\""
632 << collectinfo->numBytes
633 << "\"</td></tr>\n"
634
635 << "<tr><th>preferred receptionist</th><td>\""
636 << collectinfo->receptionist
637 << "\"</td></tr>\n"
638
639 << "</table>";
640
641 } else {
642 textout << "ERROR (statusaction::output_collectioninfo): while getting collect information\n";
643 }
644
645
646 InfoFiltersResponse_t filterinfo;
647 InfoFilterOptionsRequest_t filteroptions_request;
648 InfoFilterOptionsResponse_t filteroptions;
649 comerror_t err;
650 rproto->get_filterinfo (arg_c, filterinfo, err, logout);
651 if (err == noError) {
652 text_tset::iterator filternames_here = filterinfo.filterNames.begin();
653 text_tset::iterator filternames_end = filterinfo.filterNames.end();
654 while (filternames_here != filternames_end) {
655 textout << outconvert
656 << "<hr>\n"
657 << "<h3>Filter options for \"" << (*filternames_here) << "\"</h3>\n"
658 << "<table>\n"
659 << "<tr><th>option name</th><th>type</th><th>repeatable</th>"
660 << "<th>default value</th><th>valid values</th></tr>\n";
661
662 filteroptions_request.clear();
663 filteroptions_request.filterName = *filternames_here;
664 rproto->get_filteroptions (arg_c, filteroptions_request,
665 filteroptions, err, logout);
666 if (err == noError) {
667 FilterOption_tmap::iterator filteropt_here =
668 filteroptions.filterOptions.begin();
669 FilterOption_tmap::iterator filteropt_end =
670 filteroptions.filterOptions.end();
671 while (filteropt_here != filteropt_end) {
672 textout << outconvert
673 << "<tr><td>\""
674 << (*filteropt_here).second.name
675 << "\"</td>\n"
676
677 << "<td>";
678 text_t type_string;
679 switch ((*filteropt_here).second.type) {
680 case FilterOption_t::booleant: type_string = "boolean"; break;
681 case FilterOption_t::integert: type_string = "integer"; break;
682 case FilterOption_t::enumeratedt: type_string = "enumerated"; break;
683 case FilterOption_t::stringt: type_string = "string"; break;
684 }
685 textout << outconvert
686 << type_string
687 << "</td>\n"
688
689 << "<td>";
690 text_t repeat_string;
691 switch ((*filteropt_here).second.repeatable) {
692 case FilterOption_t::onePerQuery: repeat_string = "one per query"; break;
693 case FilterOption_t::onePerTerm: repeat_string = "one per term"; break;
694 case FilterOption_t::nPerTerm: repeat_string = "n per term"; break;
695 }
696 textout << outconvert
697 << repeat_string
698 << "</td>\n"
699
700 << "<td>\""
701 << (*filteropt_here).second.defaultValue
702 << "\"</td>\n"
703
704 << "<td>";
705
706 text_tarray::iterator valid_here =
707 (*filteropt_here).second.validValues.begin();
708 text_tarray::iterator valid_end =
709 (*filteropt_here).second.validValues.end();
710 bool valid_first = true;
711 while (valid_here != valid_end) {
712 if (!valid_first) textout << outconvert << ", ";
713 valid_first = false;
714 textout << outconvert << "\"" << *valid_here << "\"";
715 valid_here++;
716 }
717 textout << outconvert
718 << "</td></tr>\n";
719
720 filteropt_here++;
721 }
722
723 textout << outconvert
724 << "</table>\n";
725
726 } else {
727 textout << outconvert << "Error (" << get_comerror_string (err)
728 << ") while getting filter option information\n";
729 }
730
731 filternames_here++;
732 }
733
734 } else {
735 textout << outconvert << "Error (" << get_comerror_string (err)
736 << ") while getting filter information\n";
737 }
738 }
739
740 textout << outconvert << disp << "_status:infofooter_\n";
741}
742
743void statusaction::output_initlog (cgiargsclass &/*args*/, displayclass &disp,
744 outconvertclass &outconvert,
745 ostream &textout, ostream &/*logout*/) {
746 if (recpt == NULL) return;
747 const recptconf &rcinfo = recpt->get_configinfo ();
748 text_t initfilename = filename_cat (rcinfo.gsdlhome, "etc", "initout.txt");
749 char *cinitfilename = initfilename.getcstr();
750 if (cinitfilename == NULL) return;
751
752 textout << outconvert << disp << "_status:infoheader_(Init log)\n";
753 textout << outconvert << "<h2>Init log</h2>\n";
754
755#ifdef GSDL_USE_IOS_H
756 ifstream initin (cinitfilename, ios::in | ios::nocreate);
757#else
758 ifstream initin (cinitfilename, ios::in);
759#endif
760
761 delete cinitfilename;
762 if (initin) {
763 textout << outconvert << "<p>The initialisation error log, "
764 << initfilename << ", contains the\n";
765 textout << outconvert << "following information:\n\n";
766 text_t errorpage = "<p><pre>\n";
767
768 char c;
769 initin.get(c);
770 while (!initin.eof ()) {
771 errorpage.push_back(c);
772 initin.get(c);
773 }
774
775 errorpage += "</pre>\n";
776 initin.close();
777 textout << outconvert << errorpage;
778
779 } else {
780 textout << outconvert << "Couldn't read initialisation error log, "
781 << initfilename << ".\n";
782 }
783
784 textout << outconvert << disp << "_status:infofooter_\n";
785}
786
787void statusaction::output_errorlog (cgiargsclass &/*args*/, displayclass &disp,
788 outconvertclass &outconvert,
789 ostream &textout, ostream &logout) {
790 if (recpt == NULL) return;
791 const recptconf &rcinfo = recpt->get_configinfo ();
792 text_t errfilename = filename_cat (rcinfo.gsdlhome, "etc", "errout.txt");
793 char *cerrfilename = errfilename.getcstr();
794 if (cerrfilename == NULL) return;
795
796 textout << outconvert << disp << "_status:infoheader_(Error log)\n";
797 textout << outconvert << "<h2>Error log</h2>\n";
798 logout << flush;
799
800#ifdef GSDL_USE_IOS_H
801 ifstream errin (cerrfilename, ios::in | ios::nocreate);
802#else
803 ifstream errin (cerrfilename, ios::in);
804#endif
805
806 delete cerrfilename;
807 if (errin) {
808 textout << outconvert << "<p>The error log, "
809 << errfilename << ", contains the\n";
810 textout << outconvert << "following information:\n\n";
811 text_t errorpage = "<p><pre>\n";
812
813 char c;
814 errin.get(c);
815 while (!errin.eof ()) {
816 errorpage.push_back(c);
817 errin.get(c);
818 }
819
820 errorpage += "</pre>\n";
821 errin.close();
822 textout << outconvert << errorpage;
823
824 } else {
825 textout << outconvert << "Couldn't read error log, "
826 << errfilename << ".\n";
827 }
828
829 textout << outconvert << disp << "_status:infofooter_\n";
830}
831
832void statusaction::output_errorpage (outconvertclass &outconvert,
833 ostream &textout, ostream &/*logout*/,
834 text_t message) {
835 textout << outconvert
836 << "<html>\n"
837 << "<head>\n"
838 << "<title>Error</title>\n"
839 << "</head>\n"
840 << "<body bgcolor=\"#ffffff\" text=\"#000000\" link=\"#006666\" "
841 << "alink=\"#cc9900\" vlink=\"#666633\">\n"
842 << "<h2>Oops!</h2>\n"
843 << message
844 << "\n</body>\n"
845 << "</html>\n";
846 return;
847}
848
849
850
851statusaction::statusaction () {
852 disabled = true;
853 recpt = NULL;
854
855 // this action uses cgi variable "a"
856 cgiarginfo arg_ainfo;
857 arg_ainfo.shortname = "a";
858 arg_ainfo.longname = "action";
859 arg_ainfo.multiplechar = true;
860 arg_ainfo.defaultstatus = cgiarginfo::weak;
861 arg_ainfo.argdefault = "status";
862 arg_ainfo.savedarginfo = cgiarginfo::must;
863 argsinfo.addarginfo (NULL, arg_ainfo);
864
865 // "sp" -- status page
866 arg_ainfo.shortname = "sp";
867 arg_ainfo.longname = "status page";
868 arg_ainfo.multiplechar = true;
869 arg_ainfo.defaultstatus = cgiarginfo::good;
870 arg_ainfo.argdefault = "frameset";
871 arg_ainfo.savedarginfo = cgiarginfo::can;
872 argsinfo.addarginfo (NULL, arg_ainfo);
873
874 // "pr" -- protocol
875 arg_ainfo.shortname = "pr";
876 arg_ainfo.longname = "protocol";
877 arg_ainfo.multiplechar = true;
878 arg_ainfo.defaultstatus = cgiarginfo::none;
879 arg_ainfo.argdefault = "";
880 arg_ainfo.savedarginfo = cgiarginfo::can;
881 argsinfo.addarginfo (NULL, arg_ainfo);
882}
883
884statusaction::~statusaction () {
885}
886
887bool statusaction::check_cgiargs (cgiargsinfoclass &/*argsinfo*/, cgiargsclass &/*args*/,
888 ostream &/*logout*/) {
889 return true;
890}
891
892void statusaction::get_cgihead_info (cgiargsclass &/*args*/, recptprotolistclass * /*protos*/,
893 response_t &response, text_t &response_data,
894 ostream &/*logout*/) {
895 response = content;
896 response_data = "text/html";
897}
898
899bool statusaction::do_action (cgiargsclass &args, recptprotolistclass *protos,
900 browsermapclass * /*browsers*/, displayclass &disp,
901 outconvertclass &outconvert, ostream &textout,
902 ostream &logout) {
903 // make sure the status function is enabled
904 if (disabled) {
905 output_errorpage (outconvert, textout, logout,
906 "The status action is disabled. "
907 "See the documentation (what documentation!) on how "
908 "to enable it.");
909 return true;
910 }
911
912 // make sure we know about a receptionist
913 if (recpt == NULL) {
914 output_errorpage (outconvert, textout, logout,
915 "The status action does not contain information\n"
916 "about any receptionists. The method set_receptionist\n"
917 "was probably not called from the module which instantiated\n"
918 "this status action.\n");
919 return true;
920 }
921
922 // check to make sure status.dm was read in
923 const recptconf &rcinfo = recpt->get_configinfo ();
924 text_tset::const_iterator macrohere = rcinfo.macrofiles.begin ();
925 text_tset::const_iterator macroend = rcinfo.macrofiles.end ();
926 while (macrohere != macroend) {
927 if (*macrohere == "status.dm") break;
928 macrohere++;
929 }
930 if (macrohere == macroend) {
931 output_errorpage (outconvert, textout, logout,
932 "The status.dm file was not read in. This macro file is\n"
933 "needed to display configuration and status information.\n");
934 return true;
935 }
936
937 // output the required status page
938 text_t &arg_sp = args["sp"];
939 if (arg_sp == "frameset") output_frameset (args, disp, outconvert, textout, logout);
940 else if (arg_sp == "select") output_select (args, disp, outconvert, textout, logout);
941 else if (arg_sp == "welcome") output_welcome (args, protos, disp, outconvert, textout, logout);
942 else if (arg_sp == "generalinfo") output_generalinfo (args, disp, outconvert, textout, logout);
943 else if (arg_sp == "argumentinfo") output_argumentinfo (args, disp, outconvert, textout, logout);
944 else if (arg_sp == "actioninfo") output_actioninfo (args, disp, outconvert, textout, logout);
945 else if (arg_sp == "browserinfo") output_browserinfo (args, disp, outconvert, textout, logout);
946 else if (arg_sp == "protocolinfo") output_protocolinfo (args, disp, outconvert, textout, logout);
947 else if (arg_sp == "collectioninfo") output_collectioninfo (args, disp, outconvert, textout, logout);
948 else if (arg_sp == "initlog") output_initlog (args, disp, outconvert, textout, logout);
949 else if (arg_sp == "errorlog") output_errorlog (args, disp, outconvert, textout, logout);
950 else {
951 output_errorpage (outconvert, textout, logout,
952 "Unknown page \"" + arg_sp + "\".\n");
953 }
954
955 return true;
956}
957
958void statusaction::configure (const text_t &key, const text_tarray &cfgline) {
959 if ((key == "status") && (cfgline.size() == 1) &&
960 (cfgline[0] == "true" || cfgline[0] == "on" || cfgline[0] == "enabled")) {
961 disabled = false;
962 } else {
963 // call the parent class to deal with the things which
964 // are not dealt with here
965 action::configure (key, cfgline);
966 }
967}
Note: See TracBrowser for help on using the repository browser.