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

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

minor modifications to get web library compiling under VC++ 6.0

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