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