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

Last change on this file since 226 was 220, checked in by rjmcnab, 25 years ago

Altered the protocol so that the metadata is part of the filter.

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 4.7 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 220 1999-03-31 23:44:49Z rjmcnab $
9 *
10 *********************************************************************/
11
12/*
13 $Log$
14 Revision 1.4 1999/03/31 23:44:48 rjmcnab
15 Altered the protocol so that the metadata is part of the filter.
16
17 Revision 1.3 1999/03/03 23:26:35 sjboddie
18
19 Implemented more of the protocol
20
21 Revision 1.2 1999/02/25 21:58:58 rjmcnab
22
23 Merged sources.
24
25 Revision 1.1 1999/02/21 22:35:22 rjmcnab
26
27 Initial revision.
28
29 */
30
31
32#include "nullproto.h"
33#include "colservrconfig.h"
34#include <assert.h>
35
36
37// this configure will configure each of the collection servers
38void nullproto::configure (const text_t &key, const text_tarray &cfgline) {
39 // the naming of the collection should not be done here,
40 // it should be done just after the collection server has been
41 // created
42 if (key == "collection") return;
43
44 collectservermapclass::iterator here = cservers.begin();
45 collectservermapclass::iterator end = cservers.end();
46
47 while (here != end) {
48 assert ((*here).second.c != NULL);
49 if ((*here).second.c != NULL) {
50 (*here).second.c->configure (key, cfgline);
51 }
52
53 here++;
54 }
55}
56
57// this init will configure and init each of the collection servers
58bool nullproto::init (ostream &logout) {
59 collectservermapclass::iterator here = cservers.begin();
60 collectservermapclass::iterator end = cservers.end();
61
62 while (here != end) {
63 assert ((*here).second.c != NULL);
64 if ((*here).second.c != NULL) {
65 const colservrconf &configinfo = (*here).second.c->get_configinfo ();
66
67 // configure this collection server
68 if (!collect_cfg_read (*((*here).second.c), configinfo.gsdlhome,
69 configinfo.collection)) {
70 outconvertclass text_t2ascii;
71 logout << text_t2ascii
72 << "Error: couldn't read collect.cfg file for collection \""
73 << configinfo.collection << "\", gsdlhome=\""
74 << configinfo.gsdlhome << "\"\n";
75 return false;
76 }
77
78 if (!build_cfg_read (*((*here).second.c), configinfo.gsdlhome,
79 configinfo.collection)) {
80 outconvertclass text_t2ascii;
81 logout << text_t2ascii
82 << "Error: couldn't read build.cfg file for collection \""
83 << configinfo.collection << "\", gsdlhome=\""
84 << configinfo.gsdlhome << "\"\n";
85 return false;
86 }
87
88 if (!(*here).second.c->init (logout)) return false;
89 }
90 here++;
91 }
92
93 return true;
94}
95
96text_t nullproto::get_protocol_name () {
97 return "nullproto";
98}
99
100
101void nullproto::get_collection_list (text_tarray &collist, comerror_t &err,
102 ostream &/*logout*/) {
103 collist.erase(collist.begin(),collist.end());
104 err = noError;
105
106 collectservermapclass::iterator here = cservers.begin();
107 collectservermapclass::iterator end = cservers.end();
108 while (here != end) {
109 assert ((*here).second.c != NULL);
110 if ((*here).second.c != NULL) {
111 collist.push_back ((*here).second.c->get_collection_name());
112 }
113 here++;
114 }
115}
116
117void nullproto::has_collection (const text_t &collection, bool &hascollection,
118 comerror_t &err, ostream &/*logout*/) {
119 hascollection = (cservers.getcollectserver(collection) != NULL);
120 err = noError;
121}
122
123void nullproto::ping (const text_t &collection, bool &wassuccess,
124 comerror_t &err, ostream &/*logout*/) {
125 wassuccess = (cservers.getcollectserver(collection) != NULL);
126 err = noError;
127}
128
129void nullproto::get_collectinfo (const text_t &collection,
130 ColInfoResponse_t &collectinfo,
131 comerror_t &err, ostream &logout) {
132 collectserver *cserver = cservers.getcollectserver (collection);
133 if (cserver != NULL) cserver->get_collectinfo (collectinfo, err, logout);
134 else err = protocolError;
135}
136
137
138void nullproto::get_filterinfo (const text_t &collection,
139 InfoFiltersResponse_t &response,
140 comerror_t &err, ostream &logout) {
141 collectserver *cserver = cservers.getcollectserver (collection);
142 if (cserver != NULL) cserver->get_filterinfo (response, err, logout);
143 else err = protocolError;
144}
145
146void nullproto::get_filteroptions (const text_t &collection,
147 const InfoFilterOptionsRequest_t &request,
148 InfoFilterOptionsResponse_t &response,
149 comerror_t &err, ostream &logout) {
150 collectserver *cserver = cservers.getcollectserver (collection);
151 if (cserver != NULL) cserver->get_filteroptions (request, response, err, logout);
152 else err = protocolError;
153}
154
155void nullproto::filter (const text_t &collection,
156 const FilterRequest_t &request,
157 FilterResponse_t &response,
158 comerror_t &err, ostream &logout) {
159 collectserver *cserver = cservers.getcollectserver (collection);
160 if (cserver != NULL) cserver->filter (request, response, err, logout);
161 else err = protocolError;
162}
163
Note: See TracBrowser for help on using the repository browser.