1 | /**********************************************************************
|
---|
2 | *
|
---|
3 | * nullproto.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 "nullproto.h"
|
---|
27 | #include <assert.h>
|
---|
28 |
|
---|
29 | #include "filter.h"
|
---|
30 | #include "browsefilter.h"
|
---|
31 | #include "mgqueryfilter.h"
|
---|
32 | #include "mgppqueryfilter.h"
|
---|
33 | #include "infodbclass.h"
|
---|
34 | #include "mggdbmsource.h"
|
---|
35 | #include "mgsearch.h"
|
---|
36 | #include "mgppsearch.h"
|
---|
37 | #include "fileutil.h"
|
---|
38 |
|
---|
39 |
|
---|
40 | nullproto::~nullproto() {
|
---|
41 | }
|
---|
42 |
|
---|
43 | // add_collection sets up the collectionserver and calls
|
---|
44 | // add_collectserver
|
---|
45 | /*
|
---|
46 | void nullproto::add_collection (const text_t &collection, void *recpt,
|
---|
47 | const text_t &gsdlhome, const text_t &gdbmhome) {
|
---|
48 | }
|
---|
49 | */
|
---|
50 |
|
---|
51 | // remove_collection deletes the collection server of collection.
|
---|
52 | // This only needs to be called if a collectionserver is to be
|
---|
53 | // removed while the library is running. The destructor function
|
---|
54 | // cleans up all collectservers when the program exits.
|
---|
55 | void nullproto::remove_collection (const text_t &collection, ostream &logout) {
|
---|
56 | cset->remove_collection(collection, logout);
|
---|
57 | }
|
---|
58 |
|
---|
59 | // this configure will configure each of the collection servers
|
---|
60 | void nullproto::configure (const text_t &key, const text_tarray &cfgline) {
|
---|
61 | // the naming of the collection should not be done here,
|
---|
62 | // it should be done just after the collection server has been
|
---|
63 | // created
|
---|
64 |
|
---|
65 | // the protocol should not configure the collection set; it should be
|
---|
66 | // done direct to the collection server set
|
---|
67 | if (key == "gsdlhome") {
|
---|
68 | cset->configure(key, cfgline);
|
---|
69 | }
|
---|
70 | }
|
---|
71 |
|
---|
72 | // this init will configure and init each of the collection servers
|
---|
73 | bool nullproto::init (ostream &logout) {
|
---|
74 | return cset->init(logout);
|
---|
75 | }
|
---|
76 |
|
---|
77 | text_t nullproto::get_site_name () {
|
---|
78 | return "";
|
---|
79 | }
|
---|
80 |
|
---|
81 | text_t nullproto::get_protocol_name () {
|
---|
82 | return "nullproto";
|
---|
83 | }
|
---|
84 |
|
---|
85 |
|
---|
86 | void nullproto::get_collection_list (text_tarray &collist, comerror_t &err,
|
---|
87 | ostream &/*logout*/) {
|
---|
88 | cset->getCollectionList(collist);
|
---|
89 | err = noError; // no error is guaranteed - collection server shouldn't
|
---|
90 | // about receptionist error states, logout is irrelevant
|
---|
91 | }
|
---|
92 |
|
---|
93 | void nullproto::has_collection (const text_t &collection, bool &hascollection,
|
---|
94 | comerror_t &err, ostream &/*logout*/) {
|
---|
95 | hascollection = (cset->getCollectServer(collection) != NULL);
|
---|
96 | err = noError;
|
---|
97 | }
|
---|
98 |
|
---|
99 | void nullproto::ping (const text_t &collection, bool &wassuccess,
|
---|
100 | comerror_t &err, ostream &/*logout*/) {
|
---|
101 | wassuccess = (cset->getCollectServer(collection) != NULL);
|
---|
102 | err = noError;
|
---|
103 | }
|
---|
104 |
|
---|
105 | void nullproto::get_collectinfo (const text_t &collection,
|
---|
106 | ColInfoResponse_t &collectinfo,
|
---|
107 | comerror_t &err, ostream &logout) {
|
---|
108 | collectserver *cserver = cset->getCollectServer (collection);
|
---|
109 | if (cserver != NULL) cserver->get_collectinfo (collectinfo, err, logout);
|
---|
110 | else err = protocolError;
|
---|
111 | }
|
---|
112 |
|
---|
113 |
|
---|
114 | void nullproto::get_filterinfo (const text_t &collection,
|
---|
115 | InfoFiltersResponse_t &response,
|
---|
116 | comerror_t &err, ostream &logout) {
|
---|
117 | collectserver *cserver = cset->getCollectServer (collection);
|
---|
118 | if (cserver != NULL) cserver->get_filterinfo (response, err, logout);
|
---|
119 | else err = protocolError;
|
---|
120 | }
|
---|
121 |
|
---|
122 | void nullproto::get_filteroptions (const text_t &collection,
|
---|
123 | const InfoFilterOptionsRequest_t &request,
|
---|
124 | InfoFilterOptionsResponse_t &response,
|
---|
125 | comerror_t &err, ostream &logout) {
|
---|
126 | collectserver *cserver = cset->getCollectServer (collection);
|
---|
127 | if (cserver != NULL) cserver->get_filteroptions (request, response, err, logout);
|
---|
128 | else err = protocolError;
|
---|
129 | }
|
---|
130 |
|
---|
131 | void nullproto::filter (const text_t &collection,
|
---|
132 | FilterRequest_t &request,
|
---|
133 | FilterResponse_t &response,
|
---|
134 | comerror_t &err, ostream &logout) {
|
---|
135 | collectserver *cserver = cset->getCollectServer (collection);
|
---|
136 | if (cserver != NULL) cserver->filter (request, response, err, logout);
|
---|
137 | else err = protocolError;
|
---|
138 | }
|
---|
139 |
|
---|
140 | void nullproto::get_document (const text_t &collection,
|
---|
141 | const DocumentRequest_t &request,
|
---|
142 | DocumentResponse_t &response,
|
---|
143 | comerror_t &err, ostream &logout) {
|
---|
144 | collectserver *cserver = cset->getCollectServer (collection);
|
---|
145 | if (cserver != NULL) cserver->get_document (request, response, err, logout);
|
---|
146 | else err = protocolError;
|
---|
147 | }
|
---|