1 | /**********************************************************************
|
---|
2 | *
|
---|
3 | * collectserver.cpp --
|
---|
4 | * Copyright (C) 1999 The New Zealand Digital Library Project
|
---|
5 | *
|
---|
6 | * PUT COPYRIGHT NOTICE HERE
|
---|
7 | *
|
---|
8 | * $Id: collectserver.cpp 186 1999-03-03 23:28:29Z sjboddie $
|
---|
9 | *
|
---|
10 | *********************************************************************/
|
---|
11 |
|
---|
12 | /*
|
---|
13 | $Log$
|
---|
14 | Revision 1.2 1999/03/03 23:28:29 sjboddie
|
---|
15 |
|
---|
16 | Provided stub functions for the protocol
|
---|
17 |
|
---|
18 | Revision 1.1 1999/02/21 22:32:56 rjmcnab
|
---|
19 |
|
---|
20 | Initial revision.
|
---|
21 |
|
---|
22 | */
|
---|
23 |
|
---|
24 |
|
---|
25 | #include "collectserver.h"
|
---|
26 | #include <assert.h>
|
---|
27 |
|
---|
28 |
|
---|
29 | collectserver::collectserver () {
|
---|
30 | configinfo.collection = "null";
|
---|
31 | }
|
---|
32 |
|
---|
33 | collectserver::~collectserver () {
|
---|
34 | }
|
---|
35 |
|
---|
36 | // configure should be called for each line in the
|
---|
37 | // configuration files to configure the collection server and everything
|
---|
38 | // it contains. The configuration should take place just before initialisation.
|
---|
39 | void collectserver::configure (const text_t &key, const text_tarray &cfgline) {
|
---|
40 | // configure the collection server
|
---|
41 | if (cfgline.size() >= 1) {
|
---|
42 | const text_t &value = cfgline[0];
|
---|
43 | if (key == "gsdlhome") configinfo.gsdlhome = value;
|
---|
44 | else if (key == "collection") {
|
---|
45 | configinfo.collection = value;
|
---|
46 | collectinfo.shortInfo.name = value;
|
---|
47 | } else if (key == "collectdir") configinfo.collectdir = value;
|
---|
48 | else if (key == "host") collectinfo.shortInfo.host = value;
|
---|
49 | else if (key == "port") collectinfo.shortInfo.port = value.getint();
|
---|
50 | else if (key == "public") {
|
---|
51 | if (value == "true") collectinfo.isPublic = true;
|
---|
52 | else collectinfo.isPublic = false;
|
---|
53 | } else if (key == "beta") {
|
---|
54 | if (value == "true") collectinfo.isBeta = true;
|
---|
55 | else collectinfo.isBeta = false;
|
---|
56 | } else if (key == "builddate") collectinfo.buildDate = value.getint();
|
---|
57 | else if (key == "languages") collectinfo.languages = cfgline;
|
---|
58 | else if (key == "numdocs") collectinfo.numDocs = value.getint();
|
---|
59 | else if (key == "numwords") collectinfo.numWords = value.getint();
|
---|
60 | else if (key == "numbytes") collectinfo.numBytes = value.getint();
|
---|
61 | }
|
---|
62 | }
|
---|
63 |
|
---|
64 | void collectserver::configure (const text_t &key, const text_t &value) {
|
---|
65 | text_tarray cfgline;
|
---|
66 | cfgline.push_back (value);
|
---|
67 | configure(key, cfgline);
|
---|
68 | }
|
---|
69 |
|
---|
70 |
|
---|
71 | bool collectserver::init (ostream &/*logout*/) {
|
---|
72 | return true;
|
---|
73 | }
|
---|
74 |
|
---|
75 |
|
---|
76 | void collectserver::get_collectinfo (ColInfoResponse_t &reponse,
|
---|
77 | comerror_t &err, ostream &/*logout*/) {
|
---|
78 | reponse = collectinfo;
|
---|
79 | err = noError;
|
---|
80 | }
|
---|
81 |
|
---|
82 | void collectserver::get_filteroptions (InfoFilterOptionsResponse_t &response,
|
---|
83 | comerror_t &err, ostream &/*logout*/) {
|
---|
84 | err = noError;
|
---|
85 | }
|
---|
86 |
|
---|
87 | void collectserver::filter (const FilterRequest_t &request,
|
---|
88 | FilterResponse_t &response,
|
---|
89 | comerror_t &err, ostream &/*logout*/) {
|
---|
90 | err = noError;
|
---|
91 | }
|
---|
92 |
|
---|
93 | void collectserver::get_metadataoptions (MetadataInfoResponse_t &response,
|
---|
94 | comerror_t &err, ostream &/*logout*/) {
|
---|
95 | err = noError;
|
---|
96 | }
|
---|
97 |
|
---|
98 | void collectserver::get_metadata (const MetadataRequest_t &request,
|
---|
99 | MetadataResponse_t &response,
|
---|
100 | comerror_t &err, ostream &/*logout*/) {
|
---|
101 | err = noError;
|
---|
102 | }
|
---|
103 |
|
---|
104 |
|
---|
105 |
|
---|
106 |
|
---|
107 | // thecollectserver remains the property of the calling code but
|
---|
108 | // should not be deleted until it is removed from this list.
|
---|
109 | void collectservermapclass::addcollectserver (collectserver *thecollectserver) {
|
---|
110 | // can't add a null collection server
|
---|
111 | assert (thecollectserver != NULL);
|
---|
112 | if (thecollectserver == NULL) return;
|
---|
113 |
|
---|
114 | // can't add an collection server with no collection name
|
---|
115 | assert (!(thecollectserver->get_collection_name()).empty());
|
---|
116 | if ((thecollectserver->get_collection_name()).empty()) return;
|
---|
117 |
|
---|
118 | collectserverptr cptr;
|
---|
119 | cptr.c = thecollectserver;
|
---|
120 | collectserverptrs[thecollectserver->get_collection_name()] = cptr;
|
---|
121 | }
|
---|
122 |
|
---|
123 | // getcollectserver will return NULL if the collectserver could not be found
|
---|
124 | collectserver *collectservermapclass::getcollectserver (const text_t &collection) {
|
---|
125 | // can't find a collection with no name
|
---|
126 | assert (!collection.empty());
|
---|
127 | if (collection.empty()) return NULL;
|
---|
128 |
|
---|
129 | iterator here = collectserverptrs.find (collection);
|
---|
130 | if (here == collectserverptrs.end()) return NULL;
|
---|
131 |
|
---|
132 | return (*here).second.c;
|
---|
133 | }
|
---|
134 |
|
---|