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

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

tidied up status pages and end-user collection building

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