root/main/trunk/greenstone2/runtime-src/src/protocol/recptproto.cpp @ 24959

Revision 24959, 6.1 KB (checked in by ak19, 8 years ago)

Second commit to do with Greenstone's support for RSS. Has been tested on Linux, and works if zextra.dm and base.dm are setup properly and if the rss-items.rdf file generated by the update to BasePlugout? is moved to the index folder. Modified Dr Bainbridge's code to make the way that rssaction.cpp accesses the rss-items.rdf file independent of where the GS server is located, by adding a new method to get the rss-items.rdf file's contents to the recptproto protocol class and implementing it in nullproto. The method is also mirrored in corba/corbaproto, however compilation with corba fails in a part of the code that I've not modified.

  • Property svn:executable set to *
Line 
1/**********************************************************************
2 *
3 * recptproto.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 "recptproto.h"
27#include <assert.h>
28
29
30// add collection server to protocol
31void recptproto::add_collection (const text_t &/*collection*/, void * /*recpt*/,
32                 const text_t &/*gsdlhome*/, const text_t& /*collecthome */,
33                 const text_t &/*dbhome*/)
34{
35}
36
37void recptproto::remove_collection (const text_t &/*collection*/, ostream &/*logout*/) {
38}
39
40// configure should be called for each line in the configuration file
41void recptproto::configure (const text_t &/*key*/, const text_tarray &/*cfgline*/, comerror_t &) {
42}
43
44// init should be called after the configuration but before any other
45// functions are called. If init returns false a message will be written
46// out to the log file and no other output should be produced.
47bool recptproto::init (comerror_t &err, ostream &/*logout*/) {
48  return true;
49}
50
51// get site name should return the name of the site used.
52// This is trivially empty in the case of a null protocol.  If a remote
53// connection to a site is being used then this should return the name
54// used to label a site
55text_t recptproto::get_site_name(comerror_t &err) {
56  return "localhost";
57}
58
59// get_protocol_name should return the name of this protocol (e.g. recptproto)
60// that can be used to do run time type identification and display information
61// about the protocol.
62text_t recptproto::get_protocol_name (comerror_t &err) {
63  return "recptproto";
64}
65
66// get_collection_list returns the list of collections that
67// this protocol knows about
68void recptproto::get_collection_list (text_tarray &collist, comerror_t &err,
69                      ostream &/*logout*/) {
70  collist.erase(collist.begin(),collist.end());
71  err = noError;
72}
73
74// has_collection sets 'hascollection' to be true if the protocol
75// can communicate with the collection (i.e. it is within its
76// collection list). This function should be implemented in as
77// efficient time as possible as it will be called for each page
78// access and for each protocol.
79void recptproto::has_collection (const text_t &/*collection*/, bool &hascollection,
80                 comerror_t &err, ostream &/*logout*/) {
81  hascollection = false;
82  err = noError;
83}
84
85// sets 'wassuccess' to be true if a successful ping was done to
86// the given collection.
87void recptproto::ping (const text_t &/*collection*/, bool &wassuccess,
88               comerror_t &err, ostream &/*logout*/) {
89  wassuccess = false; // no collections are supported by this class
90  err = noError;
91}
92
93// obtains general information about the collection
94void recptproto::get_collectinfo (const text_t &/*collection*/,
95                  ColInfoResponse_t &/*collectinfo*/,
96                  comerror_t &err, ostream &/*logout*/) {
97  err = protocolError;
98}
99
100// gets a list of all the filters
101void recptproto::get_filterinfo (const text_t &/*collection*/,
102                 InfoFiltersResponse_t &/*reponse*/,
103                 comerror_t &err, ostream &/*logout*/) {
104  err = protocolError;
105}
106
107// gets all the filter options for a particular filter
108void recptproto::get_filteroptions (const text_t &/*collection*/,
109                    const InfoFilterOptionsRequest_t &/*request*/,
110                    InfoFilterOptionsResponse_t &/*response*/,
111                    comerror_t &err, ostream &/*logout*/) {
112  err = protocolError;
113}
114
115// returns the contents of a collection's rss-items.rdf file (generated by BasePlugout)
116void recptproto::get_rss_items (const text_t &/*collection*/,
117                const text_t &/*gsdlhome*/,
118                text_t &/*rss_items*/,
119                comerror_t &err,
120                ostream &/*logout*/) {
121  err = protocolError;
122}
123
124// filters (search or browse) a result set
125void recptproto::filter (const text_t &/*collection*/,
126             FilterRequest_t &/*request*/,
127             FilterResponse_t &/*response*/,
128             comerror_t &err, ostream &/*logout*/) {
129  err = protocolError;
130}
131
132void recptproto::get_document (const text_t &/*collection*/,
133                   const DocumentRequest_t &/*request*/,
134                   DocumentResponse_t &/*response*/,
135                   comerror_t &err, ostream &/*logout*/) {
136  err = protocolError;
137}
138
139// sets issearchable to true if the given colection is searchable
140void recptproto::is_searchable (const text_t &/*collection*/, bool &issearchable,
141                comerror_t &err, ostream &/*logout*/) {
142  issearchable = false; // no collections are supported by this class
143  err = noError;
144}
145
146
147
148
149
150
151
152// therecptproto remains the property of the calling code but
153// should not be deleted until it is removed from this list.
154void recptprotolistclass::addrecptproto (recptproto *therecptproto) {
155  // can't add a protocol that doesn't exist
156  assert (therecptproto != NULL);
157  if (therecptproto == NULL) return;
158
159  recptprotoptr rpp;
160  rpp.p = therecptproto;
161
162  recptprotoptrs.push_back(rpp);
163}
164
165// getrecptproto will return NULL if a recptproto for the given colelction
166// could not be found
167recptproto *recptprotolistclass::getrecptproto (const text_t &collection,
168                        ostream &logout) {
169  iterator here = recptprotoptrs.begin ();
170  iterator end = recptprotoptrs.end ();
171  bool hascollection;
172  comerror_t err;
173
174  while (here != end) {
175    assert ((*here).p != NULL);
176    if ((*here).p != NULL) {
177      (*here).p->has_collection (collection, hascollection, err, logout);
178      if ((err == noError) && (hascollection == true)) return (*here).p;
179    }
180   
181    ++here;
182  }
183 
184  return NULL;
185}
Note: See TracBrowser for help on using the browser.