source: trunk/gsdl/src/recpt/nullproto.cpp@ 296

Last change on this file since 296 was 269, checked in by sjboddie, 25 years ago

small change to prevent collectdir configuration string from being passed
to everything

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 5.5 KB
Line 
1/**********************************************************************
2 *
3 * nullproto.cpp --
4 * Copyright (C) 1999 The New Zealand Digital Library Project
5 *
6 * PUT COPYRIGHT NOTICE HERE
7 *
8 * $Id: nullproto.cpp 269 1999-06-15 02:16:45Z sjboddie $
9 *
10 *********************************************************************/
11
12/*
13 $Log$
14 Revision 1.7 1999/06/15 02:16:45 sjboddie
15 small change to prevent collectdir configuration string from being passed
16 to everything
17
18 Revision 1.6 1999/05/10 03:40:41 sjboddie
19 lots of changes - slowly getting document action sorted out
20
21 Revision 1.5 1999/04/30 01:59:41 sjboddie
22 lots of stuff - getting documentaction working (documentaction replaces
23 old browseaction)
24
25 Revision 1.4 1999/03/31 23:44:48 rjmcnab
26 Altered the protocol so that the metadata is part of the filter.
27
28 Revision 1.3 1999/03/03 23:26:35 sjboddie
29
30 Implemented more of the protocol
31
32 Revision 1.2 1999/02/25 21:58:58 rjmcnab
33
34 Merged sources.
35
36 Revision 1.1 1999/02/21 22:35:22 rjmcnab
37
38 Initial revision.
39
40 */
41
42
43#include "nullproto.h"
44#include "colservrconfig.h"
45#include <assert.h>
46
47
48// this configure will configure each of the collection servers
49void nullproto::configure (const text_t &key, const text_tarray &cfgline) {
50 // the naming of the collection should not be done here,
51 // it should be done just after the collection server has been
52 // created
53 if (key == "collection" || key == "collectdir") return;
54
55 collectservermapclass::iterator here = cservers.begin();
56 collectservermapclass::iterator end = cservers.end();
57
58 while (here != end) {
59 assert ((*here).second.c != NULL);
60 if ((*here).second.c != NULL) {
61 (*here).second.c->configure (key, cfgline);
62 }
63
64 here++;
65 }
66}
67
68// this init will configure and init each of the collection servers
69bool nullproto::init (ostream &logout) {
70 collectservermapclass::iterator here = cservers.begin();
71 collectservermapclass::iterator end = cservers.end();
72
73 while (here != end) {
74 assert ((*here).second.c != NULL);
75 if ((*here).second.c != NULL) {
76 const colservrconf &configinfo = (*here).second.c->get_configinfo ();
77
78 // configure this collection server
79 if (!collect_cfg_read (*((*here).second.c), configinfo.gsdlhome,
80 configinfo.collection)) {
81 outconvertclass text_t2ascii;
82 logout << text_t2ascii
83 << "Error: couldn't read collect.cfg file for collection \""
84 << configinfo.collection << "\", gsdlhome=\""
85 << configinfo.gsdlhome << "\"\n";
86 return false;
87 }
88
89 if (!build_cfg_read (*((*here).second.c), configinfo.gsdlhome,
90 configinfo.collection)) {
91 outconvertclass text_t2ascii;
92 logout << text_t2ascii
93 << "Error: couldn't read build.cfg file for collection \""
94 << configinfo.collection << "\", gsdlhome=\""
95 << configinfo.gsdlhome << "\"\n";
96 return false;
97 }
98
99 if (!(*here).second.c->init (logout)) return false;
100 }
101 here++;
102 }
103
104 return true;
105}
106
107text_t nullproto::get_protocol_name () {
108 return "nullproto";
109}
110
111
112void nullproto::get_collection_list (text_tarray &collist, comerror_t &err,
113 ostream &/*logout*/) {
114 collist.erase(collist.begin(),collist.end());
115 err = noError;
116
117 collectservermapclass::iterator here = cservers.begin();
118 collectservermapclass::iterator end = cservers.end();
119 while (here != end) {
120 assert ((*here).second.c != NULL);
121 if ((*here).second.c != NULL) {
122 collist.push_back ((*here).second.c->get_collection_name());
123 }
124 here++;
125 }
126}
127
128void nullproto::has_collection (const text_t &collection, bool &hascollection,
129 comerror_t &err, ostream &/*logout*/) {
130 hascollection = (cservers.getcollectserver(collection) != NULL);
131 err = noError;
132}
133
134void nullproto::ping (const text_t &collection, bool &wassuccess,
135 comerror_t &err, ostream &/*logout*/) {
136 wassuccess = (cservers.getcollectserver(collection) != NULL);
137 err = noError;
138}
139
140void nullproto::get_collectinfo (const text_t &collection,
141 ColInfoResponse_t &collectinfo,
142 comerror_t &err, ostream &logout) {
143 collectserver *cserver = cservers.getcollectserver (collection);
144 if (cserver != NULL) cserver->get_collectinfo (collectinfo, err, logout);
145 else err = protocolError;
146}
147
148
149void nullproto::get_filterinfo (const text_t &collection,
150 InfoFiltersResponse_t &response,
151 comerror_t &err, ostream &logout) {
152 collectserver *cserver = cservers.getcollectserver (collection);
153 if (cserver != NULL) cserver->get_filterinfo (response, err, logout);
154 else err = protocolError;
155}
156
157void nullproto::get_filteroptions (const text_t &collection,
158 const InfoFilterOptionsRequest_t &request,
159 InfoFilterOptionsResponse_t &response,
160 comerror_t &err, ostream &logout) {
161 collectserver *cserver = cservers.getcollectserver (collection);
162 if (cserver != NULL) cserver->get_filteroptions (request, response, err, logout);
163 else err = protocolError;
164}
165
166void nullproto::filter (const text_t &collection,
167 FilterRequest_t &request,
168 FilterResponse_t &response,
169 comerror_t &err, ostream &logout) {
170 collectserver *cserver = cservers.getcollectserver (collection);
171 if (cserver != NULL) cserver->filter (request, response, err, logout);
172 else err = protocolError;
173}
174
175void nullproto::get_document (const text_t &collection,
176 const DocumentRequest_t &request,
177 DocumentResponse_t &response,
178 comerror_t &err, ostream &logout) {
179 collectserver *cserver = cservers.getcollectserver (collection);
180 if (cserver != NULL) cserver->get_document (request, response, err, logout);
181 else err = protocolError;
182}
Note: See TracBrowser for help on using the repository browser.