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