source: main/trunk/greenstone2/runtime-src/src/recpt/pingaction.cpp@ 25559

Last change on this file since 25559 was 25559, checked in by ak19, 12 years ago
  1. Dr Bainbridge fixed a bug in pingaction where it returned the message that the ping didn't succeed for any collection, even when the collection existed. 2. The pingaction no longer requires a collection argument. In the case where no collection is specified, pingaction will always return true when you call a=ping on a running GS server.
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 2.9 KB
Line 
1/**********************************************************************
2 *
3 * pingaction.cpp --
4 * Copyright (C) 1999 The New Zealand Digital Library Project
5 *
6 * A component of the Greenstone digital library software
7 * from the New Zealand Digital Library Project at the
8 * University of Waikato, New Zealand.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 *
24 *********************************************************************/
25
26#include "gsdl_modules_cfg.h"
27#ifdef GSDL_USE_PING_ACTION
28
29#include "pingaction.h"
30
31pingaction::pingaction () {
32 // this action uses cgi variable "a"
33 cgiarginfo arg_ainfo;
34 arg_ainfo.shortname = "a";
35 arg_ainfo.longname = "action";
36 arg_ainfo.multiplechar = true;
37 arg_ainfo.multiplevalue = false;
38 arg_ainfo.defaultstatus = cgiarginfo::weak;
39 arg_ainfo.argdefault = "ping";
40 arg_ainfo.savedarginfo = cgiarginfo::must;
41
42 argsinfo.addarginfo (NULL, arg_ainfo);
43
44}
45
46void pingaction::get_cgihead_info (cgiargsclass &/*args*/, recptprotolistclass * /*protos*/,
47 response_t &response, text_t &response_data,
48 ostream &/*logout*/) {
49 response = content;
50 response_data = "text/html";
51}
52
53
54bool pingaction::do_action (cgiargsclass &args, recptprotolistclass *protos,
55 browsermapclass * /*browsers*/, displayclass &/*disp*/,
56 outconvertclass &outconvert, ostream &textout,
57 ostream &logout) {
58 bool wassuccess = false;
59 comerror_t err = noError;
60
61 recptproto *collectproto = protos->getrecptproto (args["c"], logout);
62 if (!args["c"].empty() && (collectproto != NULL)) {
63 collectproto->ping (args["c"], wassuccess, err, logout);
64 if (err != noError) wassuccess = false; // a communication error
65 } else if (args["c"].empty()){ // ping-ed just the main URL
66 wassuccess = true;
67 }
68
69 textout << outconvert
70 << "<html>\n"
71 << "<head>\n"
72 << "<title>Ping</title>\n"
73 << "</head>\n"
74 << "<body>\n";
75 if(args["c"].empty()) {
76 textout << outconvert << "Ping";
77 } else {
78 textout << outconvert << "Ping for \"" << args["c"] << "\"";
79 }
80
81 if (wassuccess) {
82 textout << outconvert << " succeeded.\n";
83 } else {
84 textout << outconvert << " did not succeed.\n";
85 }
86
87 textout << outconvert
88 << "</body>\n"
89 << "</html>\n";
90
91 return true;
92};
93
94#endif //GSDL_USE_PING_ACTION
Note: See TracBrowser for help on using the repository browser.