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 172 1999-02-25 21:59:02Z rjmcnab $
|
---|
9 | *
|
---|
10 | *********************************************************************/
|
---|
11 |
|
---|
12 | /*
|
---|
13 | $Log$
|
---|
14 | Revision 1.2 1999/02/25 21:58:58 rjmcnab
|
---|
15 |
|
---|
16 | Merged sources.
|
---|
17 |
|
---|
18 | Revision 1.1 1999/02/21 22:35:22 rjmcnab
|
---|
19 |
|
---|
20 | Initial revision.
|
---|
21 |
|
---|
22 | */
|
---|
23 |
|
---|
24 |
|
---|
25 | #include "nullproto.h"
|
---|
26 | #include "colservrconfig.h"
|
---|
27 | #include <assert.h>
|
---|
28 |
|
---|
29 |
|
---|
30 | // this configure will configure each of the collection servers
|
---|
31 | void nullproto::configure (const text_t &key, const text_tarray &cfgline) {
|
---|
32 | // the naming of the collection should not be done here,
|
---|
33 | // it should be done just after the collection server has been
|
---|
34 | // created
|
---|
35 | if (key == "collection") return;
|
---|
36 |
|
---|
37 | collectservermapclass::iterator here = cservers.begin();
|
---|
38 | collectservermapclass::iterator end = cservers.end();
|
---|
39 |
|
---|
40 | while (here != end) {
|
---|
41 | assert ((*here).second.c != NULL);
|
---|
42 | if ((*here).second.c != NULL) {
|
---|
43 | (*here).second.c->configure (key, cfgline);
|
---|
44 | }
|
---|
45 |
|
---|
46 | here++;
|
---|
47 | }
|
---|
48 | }
|
---|
49 |
|
---|
50 | // this init will configure and init each of the collection servers
|
---|
51 | bool nullproto::init (ostream &logout) {
|
---|
52 | collectservermapclass::iterator here = cservers.begin();
|
---|
53 | collectservermapclass::iterator end = cservers.end();
|
---|
54 |
|
---|
55 | while (here != end) {
|
---|
56 | assert ((*here).second.c != NULL);
|
---|
57 | if ((*here).second.c != NULL) {
|
---|
58 | const colservrconf &configinfo = (*here).second.c->get_configinfo ();
|
---|
59 |
|
---|
60 | // configure this collection server
|
---|
61 | if (!collect_cfg_read (*((*here).second.c), configinfo.gsdlhome,
|
---|
62 | configinfo.collection)) {
|
---|
63 | outconvertclass text_t2ascii;
|
---|
64 | logout << text_t2ascii
|
---|
65 | << "Error: couldn't read collect.cfg file for collection \""
|
---|
66 | << configinfo.collection << "\", gsdlhome=\""
|
---|
67 | << configinfo.gsdlhome << "\"\n";
|
---|
68 | return false;
|
---|
69 | }
|
---|
70 |
|
---|
71 | if (!build_cfg_read (*((*here).second.c), configinfo.gsdlhome,
|
---|
72 | configinfo.collection)) {
|
---|
73 | outconvertclass text_t2ascii;
|
---|
74 | logout << text_t2ascii
|
---|
75 | << "Error: couldn't read build.cfg file for collection \""
|
---|
76 | << configinfo.collection << "\", gsdlhome=\""
|
---|
77 | << configinfo.gsdlhome << "\"\n";
|
---|
78 | return false;
|
---|
79 | }
|
---|
80 |
|
---|
81 | if (!(*here).second.c->init (logout)) return false;
|
---|
82 | }
|
---|
83 | here++;
|
---|
84 | }
|
---|
85 |
|
---|
86 | return true;
|
---|
87 | }
|
---|
88 |
|
---|
89 | text_t nullproto::get_protocol_name () {
|
---|
90 | return "nullproto";
|
---|
91 | }
|
---|
92 |
|
---|
93 |
|
---|
94 | void nullproto::get_collection_list (text_tarray &collist, comerror_t &err,
|
---|
95 | ostream &/*logout*/) {
|
---|
96 | collist.erase(collist.begin(),collist.end());
|
---|
97 | err = noError;
|
---|
98 |
|
---|
99 | collectservermapclass::iterator here = cservers.begin();
|
---|
100 | collectservermapclass::iterator end = cservers.end();
|
---|
101 | while (here != end) {
|
---|
102 | assert ((*here).second.c != NULL);
|
---|
103 | if ((*here).second.c != NULL) {
|
---|
104 | collist.push_back ((*here).second.c->get_collection_name());
|
---|
105 | }
|
---|
106 | here++;
|
---|
107 | }
|
---|
108 | }
|
---|
109 |
|
---|
110 | void nullproto::has_collection (const text_t &collection, bool &hascollection,
|
---|
111 | comerror_t &err, ostream &/*logout*/) {
|
---|
112 | hascollection = (cservers.getcollectserver(collection) != NULL);
|
---|
113 | err = noError;
|
---|
114 | }
|
---|
115 |
|
---|
116 | void nullproto::ping (const text_t &collection, bool &wassuccess,
|
---|
117 | comerror_t &err, ostream &/*logout*/) {
|
---|
118 | wassuccess = (cservers.getcollectserver(collection) != NULL);
|
---|
119 | err = noError;
|
---|
120 | }
|
---|
121 |
|
---|
122 | void nullproto::get_collectinfo (const text_t &collection,
|
---|
123 | ColInfoResponse_t &collectinfo,
|
---|
124 | comerror_t &err, ostream &/*logout*/) {
|
---|
125 | collectserver *cserver = cservers.getcollectserver (collection);
|
---|
126 | if (cserver != NULL) {
|
---|
127 | collectinfo = cserver->get_collectinfo ();
|
---|
128 | err = noError;
|
---|
129 |
|
---|
130 | } else {
|
---|
131 | err = protocolError;
|
---|
132 | }
|
---|
133 | }
|
---|