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