1 | /**********************************************************************
|
---|
2 | *
|
---|
3 | * corbaproto.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 | * $Id: corbaproto.mpp 1068 2000-04-04 15:11:31Z cs025 $
|
---|
25 | *
|
---|
26 | *********************************************************************/
|
---|
27 |
|
---|
28 | #include <iostream.h>
|
---|
29 | #include <fstream.h>
|
---|
30 |
|
---|
31 | // protocol headers for CORBA
|
---|
32 | #include "corbaiface.h"
|
---|
33 |
|
---|
34 | // greenstone library headers
|
---|
35 | #include "corbaconv_text_t.h"
|
---|
36 |
|
---|
37 | // greenstone local headers
|
---|
38 | #include "corbatext_t.h"
|
---|
39 |
|
---|
40 | #include "corbaproto.h"
|
---|
41 | #include "colservrconfig.h"
|
---|
42 |
|
---|
43 | // default headers
|
---|
44 | #include <assert.h>
|
---|
45 |
|
---|
46 | void corbatext_optionValueArrayToCorba(OptionValue_tarray array, corbaOptionValue_array &corba)
|
---|
47 | {
|
---|
48 | unsigned int i = 0;
|
---|
49 | OptionValue_tarray::iterator here = array.begin();
|
---|
50 | OptionValue_tarray::iterator end = array.end();
|
---|
51 |
|
---|
52 | while (here != end)
|
---|
53 | {
|
---|
54 | corba.length(i+1);
|
---|
55 |
|
---|
56 | corbaconv_text_t::getCorbatext(here->name,corba[i].name);
|
---|
57 | corbaconv_text_t::getCorbatext(here->value,corba[i].value);
|
---|
58 |
|
---|
59 | i ++;
|
---|
60 | here ++;
|
---|
61 | }
|
---|
62 | // cout << "Options " << i << endl;
|
---|
63 | }
|
---|
64 |
|
---|
65 | void corbaresponse_resultMetadataToCorba(MetadataInfo_t &meta, corbaMetadataInfo &corbaMeta)
|
---|
66 | {
|
---|
67 | corbaconv_text_t::getCorbatext(meta.params,corbaMeta.params);
|
---|
68 | corbatext_arrayToCorbaArray(meta.values, &corbaMeta.values);
|
---|
69 | corbaMeta.isRef = meta.isRef;
|
---|
70 | }
|
---|
71 |
|
---|
72 | void corbaresponse_resultMetadataToC(const corbaMetadataInfo &corbaMeta, MetadataInfo_t &meta)
|
---|
73 | {
|
---|
74 | corbaconv_text_t::setCorbatext(meta.params,corbaMeta.params);
|
---|
75 | corbatext_corbaArrayToArray(corbaMeta.values, &meta.values);
|
---|
76 | meta.isRef = corbaMeta.isRef;
|
---|
77 | }
|
---|
78 |
|
---|
79 | int corbaresponse_resultMetaParentToCorba(MetadataInfo_t *parent, corbaMetadataInfo_array &corbaparent)
|
---|
80 | {
|
---|
81 | int reply = -1, pid = -1;
|
---|
82 |
|
---|
83 | // extend for new parent
|
---|
84 | reply = corbaparent.length();
|
---|
85 | corbaparent.length(reply+1);
|
---|
86 |
|
---|
87 | // copy content into new array element
|
---|
88 | corbaresponse_resultMetadataToCorba(*parent, corbaparent[reply]);
|
---|
89 |
|
---|
90 | // deal with our own parent
|
---|
91 | if (parent->parent != NULL)
|
---|
92 | {
|
---|
93 | // get offset of new parent and extend parent vector
|
---|
94 |
|
---|
95 | pid = corbaresponse_resultMetaParentToCorba(parent->parent, corbaparent);
|
---|
96 | }
|
---|
97 | corbaparent[reply].parentid = pid;
|
---|
98 |
|
---|
99 | // return the parent id from here
|
---|
100 | return reply;
|
---|
101 | }
|
---|
102 |
|
---|
103 | MetadataInfo_t *corbaresponse_resultMetaParentToC(corbaMetadataInfo_array &corbaparent, int pid)
|
---|
104 | {
|
---|
105 | MetadataInfo_t *reply;
|
---|
106 |
|
---|
107 | reply = new MetadataInfo_t;
|
---|
108 |
|
---|
109 | corbaresponse_resultMetadataToC(corbaparent[pid], *reply);
|
---|
110 |
|
---|
111 | // deal with our own parent
|
---|
112 | if (corbaparent[pid].parentid >= 0)
|
---|
113 | {
|
---|
114 | // get offset of new parent and extend parent vector
|
---|
115 |
|
---|
116 | reply->parent = corbaresponse_resultMetaParentToC(corbaparent, corbaparent[pid].parentid);
|
---|
117 | }
|
---|
118 | else
|
---|
119 | {
|
---|
120 | reply->parent = NULL;
|
---|
121 | }
|
---|
122 |
|
---|
123 | // return the parent id from here
|
---|
124 | return reply;
|
---|
125 | }
|
---|
126 |
|
---|
127 | void corbaresponse_resultDocInfoToCorba(ResultDocInfo_tarray docinfo, corbaResultDocInfo_array &corbainfo)
|
---|
128 | {
|
---|
129 | ResultDocInfo_tarray::iterator here = docinfo.begin();
|
---|
130 | ResultDocInfo_tarray::iterator end = docinfo.end();
|
---|
131 | unsigned int i;
|
---|
132 |
|
---|
133 | i = 0;
|
---|
134 | while (here != end)
|
---|
135 | {
|
---|
136 | corbainfo.length(i+1);
|
---|
137 |
|
---|
138 | // copy the easy bits
|
---|
139 | corbaconv_text_t::getCorbatext(here->OID,corbainfo[i].OID);
|
---|
140 |
|
---|
141 | corbainfo[i].resultNum = here->result_num;
|
---|
142 | corbainfo[i].ranking = here->ranking;
|
---|
143 | corbainfo[i].termsMatched = here->num_terms_matched;
|
---|
144 | corbainfo[i].phraseMatched = here->num_phrase_match;
|
---|
145 |
|
---|
146 | // copy the docFreq array
|
---|
147 | vector<int>::iterator fhere = here->docFreq.begin();
|
---|
148 | vector<int>::iterator fend = here->docFreq.end();
|
---|
149 | unsigned int fi = 0;
|
---|
150 |
|
---|
151 | while (fhere != fend)
|
---|
152 | {
|
---|
153 | corbainfo[i].docFreq.length(fi+1);
|
---|
154 |
|
---|
155 | corbainfo[i].docFreq[fi] = *fhere;
|
---|
156 |
|
---|
157 | fhere ++;
|
---|
158 | fi ++;
|
---|
159 | }
|
---|
160 | // copy the MetadataInfo map
|
---|
161 | MetadataInfo_tmap::iterator mhere = here->metadata.begin();
|
---|
162 | MetadataInfo_tmap::iterator mend = here->metadata.end();
|
---|
163 | unsigned int mi = 0;
|
---|
164 |
|
---|
165 | while (mhere != mend)
|
---|
166 | {
|
---|
167 | corbainfo[i].metadata.names.length(mi+1);
|
---|
168 | corbainfo[i].metadata.values.length(mi+1);
|
---|
169 |
|
---|
170 | // copy name
|
---|
171 | corbaconv_text_t::getCorbatext((*mhere).first,corbainfo[i].metadata.names[mi]);
|
---|
172 |
|
---|
173 | // copy metadata
|
---|
174 | corbaresponse_resultMetadataToCorba((*mhere).second, corbainfo[i].metadata.values[mi]);
|
---|
175 | if (mhere->second.parent != NULL)
|
---|
176 | {
|
---|
177 | int pid;
|
---|
178 |
|
---|
179 | pid = corbaresponse_resultMetaParentToCorba(mhere->second.parent,
|
---|
180 | corbainfo[i].metaparents);
|
---|
181 | corbainfo[i].metadata.values[mi].parentid = pid;
|
---|
182 | }
|
---|
183 | else
|
---|
184 | {
|
---|
185 | corbainfo[i].metadata.values[mi].parentid = -1;
|
---|
186 | }
|
---|
187 |
|
---|
188 | cout << "Parent " << mi << " " << (int) &mhere->second << " " << (int) mhere->second.parent << endl;
|
---|
189 |
|
---|
190 | mhere ++;
|
---|
191 | mi ++;
|
---|
192 | }
|
---|
193 |
|
---|
194 | // Get next Docinfo item
|
---|
195 | i++;
|
---|
196 | here ++;
|
---|
197 | }
|
---|
198 | }
|
---|
199 |
|
---|
200 | void corbaresponse_resultDocInfoToC(corbaResultDocInfo_array corbainfo, ResultDocInfo_tarray &docinfo)
|
---|
201 | {
|
---|
202 | unsigned int i;
|
---|
203 | ResultDocInfo_t doc;
|
---|
204 |
|
---|
205 | for (i = 0; i < corbainfo.length(); i++)
|
---|
206 | {
|
---|
207 | corbaconv_text_t::setCorbatext(doc.OID,corbainfo[i].OID);
|
---|
208 | doc.result_num = corbainfo[i].resultNum;
|
---|
209 | doc.ranking = corbainfo[i].ranking;
|
---|
210 | doc.num_terms_matched = corbainfo[i].termsMatched;
|
---|
211 | doc.num_phrase_match = corbainfo[i].phraseMatched;
|
---|
212 |
|
---|
213 | // copy the doc freq array
|
---|
214 | unsigned int fi;
|
---|
215 | for (fi = 0; fi < corbainfo[i].docFreq.length(); fi ++)
|
---|
216 | {
|
---|
217 | doc.docFreq.push_back(corbainfo[i].docFreq[fi]);
|
---|
218 | }
|
---|
219 |
|
---|
220 | // copy the MetadataInfomap
|
---|
221 | unsigned int mi;
|
---|
222 | text_t mname;
|
---|
223 | MetadataInfo_t mdata;
|
---|
224 |
|
---|
225 | doc.metadata.clear();
|
---|
226 | for (mi = 0; mi < corbainfo[i].metadata.names.length(); mi ++)
|
---|
227 | {
|
---|
228 | // get name
|
---|
229 | corbaconv_text_t::setCorbatext(mname,corbainfo[i].metadata.names[mi]);
|
---|
230 |
|
---|
231 | // get metadata
|
---|
232 | corbaresponse_resultMetadataToC(corbainfo[i].metadata.values[mi], mdata);
|
---|
233 |
|
---|
234 | if (corbainfo[i].metadata.values[mi].parentid >= 0)
|
---|
235 | {
|
---|
236 | mdata.parent =
|
---|
237 | corbaresponse_resultMetaParentToC(corbainfo[i].metaparents,
|
---|
238 | corbainfo[i].metadata.values[mi].parentid);
|
---|
239 | }
|
---|
240 |
|
---|
241 | doc.metadata.insert(make_pair(mname, mdata));
|
---|
242 | }
|
---|
243 |
|
---|
244 | // GRB: sort out parent data
|
---|
245 | for (mi = 0; mi < corbainfo[i].metadata.names.length(); mi ++)
|
---|
246 | {
|
---|
247 | if (corbainfo[i].metadata.values[mi].parentid != 0)
|
---|
248 | {
|
---|
249 | int pi;
|
---|
250 |
|
---|
251 | for (pi = 0; pi < corbainfo[i].metadata.names.length(); pi ++)
|
---|
252 | {
|
---|
253 | if (pi != mi &&
|
---|
254 | corbainfo[i].metadata.values[mi].parentid ==
|
---|
255 | corbainfo[i].metadata.values[pi].id)
|
---|
256 | {
|
---|
257 | doc.metadata[mi].parent = &doc.metadata[pi];
|
---|
258 | }
|
---|
259 | }
|
---|
260 | }
|
---|
261 | }
|
---|
262 | // doc.metadata
|
---|
263 |
|
---|
264 | docinfo.push_back(doc);
|
---|
265 | }
|
---|
266 | }
|
---|
267 |
|
---|
268 | corbaproto::corbaproto()
|
---|
269 | { char *dummyv[1] = {""};
|
---|
270 | int dummyc = 0;
|
---|
271 | /* // CORBA variables
|
---|
272 | static CORBA::ORB_var orb = CORBA::ORB_init( dummyc , dummyv, "mico-local-orb" );
|
---|
273 | static CORBA::BOA_var boa = orb->BOA_init( dummyc , dummyv, "mico-local-boa" );
|
---|
274 |
|
---|
275 | // Get ref from "naming service"
|
---|
276 | ifstream in ("/tmp/account.objid");
|
---|
277 | char ref[1000];
|
---|
278 | in >> ref;
|
---|
279 | in.close ();
|
---|
280 |
|
---|
281 | // startup corba
|
---|
282 | static CORBA::Object_var obj = orb->string_to_object (ref);
|
---|
283 |
|
---|
284 | client = corbaiface::_narrow( obj );*/
|
---|
285 | client = NULL;
|
---|
286 | }
|
---|
287 |
|
---|
288 |
|
---|
289 | // this configure will configure each of the collection servers
|
---|
290 | void corbaproto::configure (const text_t &key, const text_tarray &cfgline) {
|
---|
291 | // the naming of the collection should not be done here,
|
---|
292 | // it should be done just after the collection server has been
|
---|
293 | // created
|
---|
294 |
|
---|
295 | // cout << "Corbaproto::Configure" << endl;
|
---|
296 |
|
---|
297 | char *dummyv[1] = {""};
|
---|
298 | int dummyc = 0;
|
---|
299 | // CORBA variables
|
---|
300 | static CORBA::ORB_var orb = CORBA::ORB_init( dummyc , dummyv, "mico-local-orb" );
|
---|
301 | static CORBA::BOA_var boa = orb->BOA_init( dummyc , dummyv, "mico-local-boa" );
|
---|
302 |
|
---|
303 | // Get ref from "naming service"
|
---|
304 | ifstream in ("/tmp/account.objid");
|
---|
305 | char ref[1000];
|
---|
306 | in >> ref;
|
---|
307 | in.close ();
|
---|
308 |
|
---|
309 | // startup corba
|
---|
310 | static CORBA::Object_var obj = orb->string_to_object (ref);
|
---|
311 |
|
---|
312 | corbaiface_var lclient = corbaiface::_narrow( obj );
|
---|
313 |
|
---|
314 | corbatext_t corbaKey;
|
---|
315 | corbatext_tarray corbaCfgline;
|
---|
316 |
|
---|
317 | corbaconv_text_t::getCorbatext(key,corbaKey);
|
---|
318 | corbatext_arrayToCorbaArray(cfgline, &corbaCfgline);
|
---|
319 |
|
---|
320 | lclient->configure(corbaKey, corbaCfgline);
|
---|
321 | }
|
---|
322 |
|
---|
323 | // this init will configure and init each of the collection servers
|
---|
324 | bool corbaproto::init (ostream &logout) {
|
---|
325 | // cout << "Corbaproto::Init" << endl;
|
---|
326 |
|
---|
327 | char *dummyv[1] = {""};
|
---|
328 | int dummyc = 0;
|
---|
329 | // CORBA variables
|
---|
330 | static CORBA::ORB_var orb = CORBA::ORB_init( dummyc , dummyv, "mico-local-orb" );
|
---|
331 | static CORBA::BOA_var boa = orb->BOA_init( dummyc , dummyv, "mico-local-boa" );
|
---|
332 |
|
---|
333 | // Get ref from "naming service"
|
---|
334 | ifstream in ("/tmp/account.objid");
|
---|
335 | char ref[1000];
|
---|
336 | in >> ref;
|
---|
337 | in.close ();
|
---|
338 |
|
---|
339 | // startup corba
|
---|
340 | static CORBA::Object_var obj = orb->string_to_object (ref);
|
---|
341 |
|
---|
342 | corbaiface_var lclient = corbaiface::_narrow( obj );
|
---|
343 |
|
---|
344 | return lclient->init();
|
---|
345 | }
|
---|
346 |
|
---|
347 | text_t corbaproto::get_protocol_name () {
|
---|
348 | return "corbaproto";
|
---|
349 | }
|
---|
350 |
|
---|
351 |
|
---|
352 | void corbaproto::get_collection_list (text_tarray &collist, comerror_t &err,
|
---|
353 | ostream &/*logout*/) {
|
---|
354 |
|
---|
355 | // cout << "Corbaproto::Collection list" << endl;
|
---|
356 |
|
---|
357 | corbatext_tarray corba_collist;
|
---|
358 | corbatext_t collection;
|
---|
359 | text_tarray tcollist;
|
---|
360 |
|
---|
361 | /* collist.erase(collist.begin(),collist.end());
|
---|
362 | err = noError;
|
---|
363 |
|
---|
364 | collectservermapclass::iterator here = cservers.begin();
|
---|
365 | collectservermapclass::iterator end = cservers.end();
|
---|
366 | while (here != end) {
|
---|
367 | assert ((*here).second.c != NULL);
|
---|
368 | if ((*here).second.c != NULL) {
|
---|
369 | collist.push_back ((*here).second.c->get_collection_name());
|
---|
370 | }
|
---|
371 | here++;
|
---|
372 | }
|
---|
373 | */
|
---|
374 | char *dummyv[1] = {""};
|
---|
375 | int dummyc = 0;
|
---|
376 | // CORBA variables
|
---|
377 | static CORBA::ORB_var orb = CORBA::ORB_init( dummyc , dummyv, "mico-local-orb" );
|
---|
378 | static CORBA::BOA_var boa = orb->BOA_init( dummyc , dummyv, "mico-local-boa" );
|
---|
379 |
|
---|
380 | // Get ref from "naming service"
|
---|
381 | ifstream in ("/tmp/account.objid");
|
---|
382 | char ref[1000];
|
---|
383 | in >> ref;
|
---|
384 | in.close ();
|
---|
385 |
|
---|
386 | // startup corba
|
---|
387 | static CORBA::Object_var obj = orb->string_to_object (ref);
|
---|
388 |
|
---|
389 | corbaiface_var lclient = corbaiface::_narrow( obj );
|
---|
390 |
|
---|
391 | lclient->collectionList(corba_collist);
|
---|
392 |
|
---|
393 | corbatext_corbaArrayToArray(corba_collist, &tcollist);
|
---|
394 | collist = tcollist;
|
---|
395 |
|
---|
396 | err = noError;
|
---|
397 | }
|
---|
398 |
|
---|
399 | void corbaproto::has_collection (const text_t &collection, bool &hascollection,
|
---|
400 | comerror_t &err, ostream &/*logout*/) {
|
---|
401 | // cout << "Corbaproto::Has collection" << endl;
|
---|
402 |
|
---|
403 | /* hascollection = (cservers.getcollectserver(collection) != NULL);
|
---|
404 | err = noError;
|
---|
405 | return;*/
|
---|
406 |
|
---|
407 | char *dummyv[1] = {""};
|
---|
408 | int dummyc = 0;
|
---|
409 | corbatext_t_var corbaCollectPtr;
|
---|
410 | corbatext_t corbaCollection;
|
---|
411 | corbaComError corbaError;
|
---|
412 | CORBA::Boolean corbaHas;
|
---|
413 |
|
---|
414 | // CORBA variables
|
---|
415 | static CORBA::ORB_var orb = CORBA::ORB_init( dummyc , dummyv, "mico-local-orb" );
|
---|
416 | static CORBA::BOA_var boa = orb->BOA_init( dummyc , dummyv, "mico-local-boa" );
|
---|
417 |
|
---|
418 | // Get ref from "naming service"
|
---|
419 | ifstream in ("/tmp/account.objid");
|
---|
420 | char ref[1000];
|
---|
421 | in >> ref;
|
---|
422 | in.close ();
|
---|
423 |
|
---|
424 | // startup corba
|
---|
425 | static CORBA::Object_var obj = orb->string_to_object (ref);
|
---|
426 |
|
---|
427 | corbaiface_var lclient = corbaiface::_narrow( obj );
|
---|
428 |
|
---|
429 | // corbaCollectPtr = &corbaCollection;
|
---|
430 | //corbatext_corbatext(collection, corbaCollectPtr);
|
---|
431 | corbaconv_text_t::getCorbatext(collection,corbaCollection);
|
---|
432 |
|
---|
433 | lclient->hasCollection(corbaCollection, corbaHas, corbaError);
|
---|
434 |
|
---|
435 | hascollection = (corbaHas != 0);
|
---|
436 | err = noError;
|
---|
437 |
|
---|
438 | }
|
---|
439 |
|
---|
440 | void corbaproto::ping (const text_t &collection, bool &wassuccess,
|
---|
441 | comerror_t &err, ostream &/*logout*/) {
|
---|
442 | // cout << "Corbaproto::Ping" << endl;
|
---|
443 |
|
---|
444 | char *dummyv[1] = {""};
|
---|
445 | int dummyc = 0;
|
---|
446 | // CORBA variables
|
---|
447 | static CORBA::ORB_var orb = CORBA::ORB_init( dummyc , dummyv, "mico-local-orb" );
|
---|
448 | static CORBA::BOA_var boa = orb->BOA_init( dummyc , dummyv, "mico-local-boa" );
|
---|
449 |
|
---|
450 | // Get ref from "naming service"
|
---|
451 | ifstream in ("/tmp/account.objid");
|
---|
452 | char ref[1000];
|
---|
453 | in >> ref;
|
---|
454 | in.close ();
|
---|
455 |
|
---|
456 | // startup corba
|
---|
457 | static CORBA::Object_var obj = orb->string_to_object (ref);
|
---|
458 |
|
---|
459 | corbaiface_var lclient = corbaiface::_narrow( obj );
|
---|
460 |
|
---|
461 | corbatext_t corbaCollect;
|
---|
462 | corbaComError corbaError;
|
---|
463 | bool success;
|
---|
464 |
|
---|
465 | corbaconv_text_t::getCorbatext(collection,corbaCollect);
|
---|
466 | success = lclient->ping(corbaCollect, corbaError);
|
---|
467 |
|
---|
468 | wassuccess = success;
|
---|
469 | /*
|
---|
470 | wassuccess = (cservers.getcollectserver(collection) != NULL);
|
---|
471 | err = noError;
|
---|
472 | */
|
---|
473 | }
|
---|
474 |
|
---|
475 | void corbaproto::get_collectinfo (const text_t &collection,
|
---|
476 | ColInfoResponse_t &collectinfo,
|
---|
477 | comerror_t &err, ostream &logout) {
|
---|
478 | // cout << "Corbaproto::Collectinfo" << endl;
|
---|
479 |
|
---|
480 | char *dummyv[1] = {""};
|
---|
481 | int dummyc = 0;
|
---|
482 |
|
---|
483 | // CORBA variables
|
---|
484 | static CORBA::ORB_var orb = CORBA::ORB_init( dummyc , dummyv, "mico-local-orb" );
|
---|
485 | static CORBA::BOA_var boa = orb->BOA_init( dummyc , dummyv, "mico-local-boa" );
|
---|
486 |
|
---|
487 | // Get ref from "naming service"
|
---|
488 | ifstream in ("/tmp/account.objid");
|
---|
489 | char ref[1000];
|
---|
490 | in >> ref;
|
---|
491 | in.close ();
|
---|
492 |
|
---|
493 | // startup corba
|
---|
494 | static CORBA::Object_var obj = orb->string_to_object (ref);
|
---|
495 |
|
---|
496 | corbaiface_var lclient = corbaiface::_narrow( obj );
|
---|
497 |
|
---|
498 | corbatext_t corbaCollection;
|
---|
499 | corbaComError corbaError;
|
---|
500 | corbaColInfoResponse corbaCollectInfo;
|
---|
501 |
|
---|
502 | corbaconv_text_t::getCorbatext(collection,corbaCollection);
|
---|
503 | lclient->getCollectInfo(corbaCollection, corbaCollectInfo, corbaError);
|
---|
504 |
|
---|
505 | collectinfo.isPublic = corbaCollectInfo.isPublic;
|
---|
506 | collectinfo.isBeta = corbaCollectInfo.isBeta;
|
---|
507 | collectinfo.buildDate = corbaCollectInfo.buildDate;
|
---|
508 | corbatext_corbaArrayToArray(corbaCollectInfo.languages, &collectinfo.languages);
|
---|
509 | collectinfo.numDocs = corbaCollectInfo.numDocs;
|
---|
510 | collectinfo.numWords = corbaCollectInfo.numWords;
|
---|
511 | collectinfo.numBytes = corbaCollectInfo.numBytes;
|
---|
512 | corbatext_corbaMapToMap(corbaCollectInfo.collectionMeta, collectinfo.collectionmeta);
|
---|
513 | corbatext_corbaMapToMap(corbaCollectInfo.format, collectinfo.format);
|
---|
514 | corbatext_corbaMapToMap(corbaCollectInfo.building, collectinfo.building);
|
---|
515 | corbaconv_text_t::setCorbatext(collectinfo.receptionist,corbaCollectInfo.receptionist);
|
---|
516 |
|
---|
517 | err = (comerror_t) corbaError;
|
---|
518 | /*
|
---|
519 | collectserver *cserver = cservers.getcollectserver (collection);
|
---|
520 | if (cserver != NULL) cserver->get_collectinfo (collectinfo, err, logout);
|
---|
521 | else err = protocolError;
|
---|
522 | */
|
---|
523 | }
|
---|
524 |
|
---|
525 |
|
---|
526 | void corbaproto::get_filterinfo (const text_t &collection,
|
---|
527 | InfoFiltersResponse_t &response,
|
---|
528 | comerror_t &err, ostream &logout) {
|
---|
529 | // cout << "Corbaproto::Filterinfo" << endl;
|
---|
530 |
|
---|
531 | char *dummyv[1] = {""};
|
---|
532 | int dummyc = 0;
|
---|
533 | // CORBA variables
|
---|
534 | static CORBA::ORB_var orb = CORBA::ORB_init( dummyc , dummyv, "mico-local-orb" );
|
---|
535 | static CORBA::BOA_var boa = orb->BOA_init( dummyc , dummyv, "mico-local-boa" );
|
---|
536 |
|
---|
537 | // Get ref from "naming service"
|
---|
538 | ifstream in ("/tmp/account.objid");
|
---|
539 | char ref[1000];
|
---|
540 | in >> ref;
|
---|
541 | in.close ();
|
---|
542 |
|
---|
543 | // startup corba
|
---|
544 | static CORBA::Object_var obj = orb->string_to_object (ref);
|
---|
545 |
|
---|
546 | corbaiface_var lclient = corbaiface::_narrow( obj );
|
---|
547 |
|
---|
548 | corbatext_t corbaCollection;
|
---|
549 | corbatext_tset corbaResponse;
|
---|
550 | corbaComError corbaError;
|
---|
551 |
|
---|
552 | corbaconv_text_t::getCorbatext(collection,corbaCollection);
|
---|
553 |
|
---|
554 | lclient->getFilterInfo(corbaCollection, corbaResponse, corbaError);
|
---|
555 |
|
---|
556 | corbatext_corbaArrayToSet(corbaResponse, &response.filterNames);
|
---|
557 |
|
---|
558 | err = (comerror_t) corbaError;
|
---|
559 |
|
---|
560 | /*
|
---|
561 | collectserver *cserver = cservers.getcollectserver (collection);
|
---|
562 | if (cserver != NULL) cserver->get_filterinfo (response, err, logout);
|
---|
563 | else err = protocolError;
|
---|
564 | */
|
---|
565 | }
|
---|
566 |
|
---|
567 | void corbaproto::get_filteroptions (const text_t &collection,
|
---|
568 | const InfoFilterOptionsRequest_t &request,
|
---|
569 | InfoFilterOptionsResponse_t &response,
|
---|
570 | comerror_t &err, ostream &logout) {
|
---|
571 | // cout << "Corbaproto::Filteroptions" << endl;
|
---|
572 |
|
---|
573 | char *dummyv[1] = {""};
|
---|
574 | int dummyc = 0;
|
---|
575 | // CORBA variables
|
---|
576 | static CORBA::ORB_var orb = CORBA::ORB_init( dummyc , dummyv, "mico-local-orb" );
|
---|
577 | static CORBA::BOA_var boa = orb->BOA_init( dummyc , dummyv, "mico-local-boa" );
|
---|
578 |
|
---|
579 | // Get ref from "naming service"
|
---|
580 | ifstream in ("/tmp/account.objid");
|
---|
581 | char ref[1000];
|
---|
582 | in >> ref;
|
---|
583 | in.close ();
|
---|
584 |
|
---|
585 | // startup corba
|
---|
586 | static CORBA::Object_var obj = orb->string_to_object (ref);
|
---|
587 |
|
---|
588 | corbaiface_var lclient = corbaiface::_narrow( obj );
|
---|
589 |
|
---|
590 | corbatext_t corbaCollection;
|
---|
591 | corbatext_t filterName;
|
---|
592 | corbaFilterOptionsResponse corbaResponse;
|
---|
593 | corbaComError corbaError;
|
---|
594 | unsigned int i;
|
---|
595 | corbaconv_text_t *cc_name;
|
---|
596 | FilterOption_t *option;
|
---|
597 |
|
---|
598 | corbaconv_text_t::getCorbatext(collection,corbaCollection);
|
---|
599 | corbaconv_text_t::getCorbatext(request.filterName,filterName);
|
---|
600 |
|
---|
601 | lclient->getFilterOptions(corbaCollection, filterName, corbaResponse, corbaError);
|
---|
602 |
|
---|
603 | for (i = 0; i < corbaResponse.names.length(); i ++)
|
---|
604 | {
|
---|
605 | cc_name = new corbaconv_text_t(corbaResponse.names[i]);
|
---|
606 |
|
---|
607 | option = new FilterOption_t;
|
---|
608 | corbaconv_text_t::setCorbatext(option->name,corbaResponse.options[i].name);
|
---|
609 | option->type = (FilterOption_t::type_t) corbaResponse.options[i].type;
|
---|
610 | option->repeatable = (FilterOption_t::repeatable_t) corbaResponse.options[i].repeatable;
|
---|
611 | corbaconv_text_t::setCorbatext(option->defaultValue,corbaResponse.options[i].defaultValue);
|
---|
612 | corbatext_corbaArrayToArray(corbaResponse.options[i].validValues, &option->validValues);
|
---|
613 |
|
---|
614 | response.filterOptions.insert(make_pair(*cc_name, *option)); // typecast to text_t
|
---|
615 | }
|
---|
616 |
|
---|
617 | err = (comerror_t) corbaError;
|
---|
618 | /*
|
---|
619 | collectserver *cserver = cservers.getcollectserver (collection);
|
---|
620 | if (cserver != NULL) cserver->get_filteroptions (request, response, err, logout);
|
---|
621 | else err = protocolError;
|
---|
622 | */
|
---|
623 | }
|
---|
624 |
|
---|
625 | void corbaproto::filter (const text_t &collection,
|
---|
626 | FilterRequest_t &request,
|
---|
627 | FilterResponse_t &response,
|
---|
628 | comerror_t &err, ostream &logout) {
|
---|
629 | // cout << "Corbaproto::Filter" << endl;
|
---|
630 |
|
---|
631 | corbaFilterRequest corbaRequest;
|
---|
632 | corbaFilterResponse corbaResponse;
|
---|
633 |
|
---|
634 | char *dummyv[1] = {""};
|
---|
635 | int dummyc = 0;
|
---|
636 | corbatext_t_var corbaCollectPtr;
|
---|
637 | corbatext_t corbaCollection;
|
---|
638 | corbaComError corbaError;
|
---|
639 |
|
---|
640 | // CORBA variables
|
---|
641 | static CORBA::ORB_var orb = CORBA::ORB_init( dummyc , dummyv, "mico-local-orb" );
|
---|
642 | static CORBA::BOA_var boa = orb->BOA_init( dummyc , dummyv, "mico-local-boa" );
|
---|
643 |
|
---|
644 | // Get ref from "naming service"
|
---|
645 | ifstream in ("/tmp/account.objid");
|
---|
646 | char ref[1000];
|
---|
647 | in >> ref;
|
---|
648 | in.close ();
|
---|
649 |
|
---|
650 | // startup corba
|
---|
651 | static CORBA::Object_var obj = orb->string_to_object (ref);
|
---|
652 |
|
---|
653 | corbaiface_var lclient = corbaiface::_narrow( obj );
|
---|
654 |
|
---|
655 | corbaconv_text_t::fillUsString(collection,&corbaCollection.text);
|
---|
656 |
|
---|
657 | corbaconv_text_t::fillUsString(request.filterName,&corbaRequest.filter.text);
|
---|
658 | corbatext_optionValueArrayToCorba(request.filterOptions, corbaRequest.filterOptions);
|
---|
659 | corbatext_arrayToCorbaArray(request.docSet, &corbaRequest.docSet);
|
---|
660 | corbaRequest.filterResultOptions = request.filterResultOptions;
|
---|
661 | corbaconv_text_t::getCorbatext(request.requestParams,corbaRequest.requestParams);
|
---|
662 | corbaconv_text_t::getCorbatext(request.refParams,corbaRequest.refParams);
|
---|
663 | corbaRequest.getParents = request.getParents;
|
---|
664 | corbatext_setToCorbaArray(request.fields, &corbaRequest.fields);
|
---|
665 |
|
---|
666 | corbaResponse.numDocs = response.numDocs;
|
---|
667 | corbaresponse_resultDocInfoToCorba(response.docInfo, corbaResponse.docInfo);
|
---|
668 |
|
---|
669 | lclient->filter (corbaCollection, corbaRequest, corbaResponse, corbaError);
|
---|
670 |
|
---|
671 | response.numDocs = corbaResponse.numDocs;
|
---|
672 | response.isApprox = corbaResponse.isApprox;
|
---|
673 | corbaresponse_resultDocInfoToC(corbaResponse.docInfo, response.docInfo);
|
---|
674 |
|
---|
675 | err = (comerror_t) corbaError;
|
---|
676 | /*
|
---|
677 | collectserver *cserver = cservers.getcollectserver (collection);
|
---|
678 | if (cserver != NULL) cserver->filter (request, response, err, logout);
|
---|
679 | else err = protocolError;
|
---|
680 | */
|
---|
681 | // cout << "Corbaproto::Filter" << endl;
|
---|
682 |
|
---|
683 | }
|
---|
684 |
|
---|
685 | void corbaproto::get_document (const text_t &collection,
|
---|
686 | const DocumentRequest_t &request,
|
---|
687 | DocumentResponse_t &response,
|
---|
688 | comerror_t &err, ostream &logout) {
|
---|
689 | // cout << "Corbaproto::Get Document" << endl;
|
---|
690 |
|
---|
691 | /* collectserver *cserver = cservers.getcollectserver (collection);
|
---|
692 | if (cserver != NULL) cserver->get_document (request, response, err, logout);
|
---|
693 | else err = protocolError;
|
---|
694 | */
|
---|
695 |
|
---|
696 | char *dummyv[1] = {""};
|
---|
697 | int dummyc = 0;
|
---|
698 |
|
---|
699 | // CORBA variables
|
---|
700 | static CORBA::ORB_var orb = CORBA::ORB_init( dummyc , dummyv, "mico-local-orb" );
|
---|
701 | static CORBA::BOA_var boa = orb->BOA_init( dummyc , dummyv, "mico-local-boa" );
|
---|
702 |
|
---|
703 | // Get ref from "naming service"
|
---|
704 | ifstream in ("/tmp/account.objid");
|
---|
705 | char ref[1000];
|
---|
706 | in >> ref;
|
---|
707 | in.close ();
|
---|
708 |
|
---|
709 | // startup corba
|
---|
710 | static CORBA::Object_var obj = orb->string_to_object (ref);
|
---|
711 |
|
---|
712 | corbaiface_var lclient = corbaiface::_narrow( obj );
|
---|
713 |
|
---|
714 | corbatext_t corbaCollect;
|
---|
715 | corbaDocRequest corbaRequest;
|
---|
716 | corbaDocResponse corbaResponse;
|
---|
717 | corbaComError corbaError;
|
---|
718 |
|
---|
719 | corbaconv_text_t::getCorbatext(collection,corbaCollect);
|
---|
720 | corbaconv_text_t::getCorbatext(request.OID,corbaRequest.OID);
|
---|
721 | corbaconv_text_t::getCorbatext(request.docType,corbaRequest.docType);
|
---|
722 | corbaconv_text_t::getCorbatext(request.docFormat,corbaRequest.docFormat);
|
---|
723 |
|
---|
724 | lclient->getDocument(corbaCollect, corbaRequest, corbaResponse, corbaError);
|
---|
725 | corbaconv_text_t::setCorbatext(response.doc,corbaResponse.doc);
|
---|
726 |
|
---|
727 | err = (comerror_t) corbaError;
|
---|
728 | }
|
---|