source: trunk/gsdl/src/recpt/corbaproto.mpp@ 2173

Last change on this file since 2173 was 2173, checked in by cs025, 23 years ago

Improvements to configure scripts in their support of various MICO
environment considerations, particularly when MICO is on the system
paths.

Fixed CORBA version of ping to correspond with parameters etc. of the
native form.

Finally, improved PING action to be more than a simple call to
the HASCOLLECTION action in the null protocol.

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