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

Last change on this file since 2112 was 1983, checked in by mjd12, 23 years ago

Modified corbaproto::filter and added corbaresponse_resultTermInfoToC to
fix bug where search terms are not highlighted (mjd12, Jan 2001).

  • Property svn:keywords set to Author Date Id Revision
File size: 22.8 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 1983 2001-02-15 02:44:52Z mjd12 $
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 // the naming of the collection should not be done here,
373 // it should be done just after the collection server has been
374 // created
375
376 // cout << "Corbaproto::Configure" << endl;
377 corbatext_t corbaKey;
378 corbatext_tarray corbaCfgline;
379
380 // get the corba client reference
381 // corbaiface_var lclient = this->getCorbaClient(); // ****
382 corbaiface_var lclient = client;
383
384 // convert all the requisite structures into their CORBA form
385 corbaconv_text_t::getCorbatext(key,corbaKey);
386 corbatext_arrayToCorbaArray(cfgline, &corbaCfgline);
387
388 // execute the corba transaction
389 lclient->configure(corbaKey, corbaCfgline);
390
391 if (key=="gsdlhome")
392 {
393 // store gsdlhome in corba prototype so it can be used later to
394 // check if icons specified in format statements exist on the
395 // recptionist's side
396 gsdlhome = cfgline[0];
397 }
398}
399
400// this init will configure and init each of the collection servers
401bool corbaproto::init (ostream &logout) {
402// cout << "Corbaproto::Init" << endl;
403
404 // get the corba client reference
405 // corbaiface_var lclient = this->getCorbaClient(); // ****
406 corbaiface_var lclient = client;
407
408 // execute the corba transaction
409 return lclient->initialise();
410}
411
412void corbaproto::cache_missing_icons(text_tmap& format_map,
413 text_t& httpdomain,
414 text_t& httpprefix)
415{
416 // consider making this a member function in the object?
417
418 text_tmap::iterator format_here = format_map.begin();
419 text_tmap::iterator format_end = format_map.end();
420 while (format_here!=format_end)
421 {
422 text_t format_line = format_here->second;
423
424 // cout << "*** format line = " << format_line << endl; // ****
425
426 text_t::iterator fl_begin = format_line.begin();
427 text_t::iterator fl_end = format_line.end();
428
429 text_t::iterator httpimg_find = findword(fl_begin,fl_end,"_httpimg_");
430 text_t::iterator http_find = httpimg_find;
431
432 while (httpimg_find!=fl_end)
433 {
434 http_find = httpimg_find+5;
435 httpimg_find += 9;
436
437 // look for white space " or >
438 text_t::iterator filename_end = httpimg_find;
439 while (filename_end != fl_end)
440 {
441 if (*filename_end == ' ') break;
442 if (*filename_end == '\t') break;
443 if (*filename_end == '\"') break;
444 if (*filename_end == '>') break;
445 filename_end++;
446 }
447
448 text_t img_filename = substr(httpimg_find,filename_end);
449
450 text_t site_img_filename = filename_cat(gsdlhome,"images",img_filename);
451
452 // look to see if img filename exists in images directory
453 if (!file_exists(site_img_filename))
454 {
455 text_t cache_img_dir
456 = filename_cat(gsdlhome,"images",".cache");
457
458 text_t remote_img_url = "http://" + httpdomain + httpprefix
459 + "/images" + img_filename;
460
461 text_t wget_cmd = "wget -q -N --directory-prefix="+cache_img_dir
462 + " " + remote_img_url;
463
464 char* wget_cmd_chars = wget_cmd.getcstr();
465
466 system(wget_cmd_chars);
467 delete wget_cmd_chars;
468
469 format_map[format_here->first]
470 = substr(fl_begin,http_find) + "cache" + substr(http_find,fl_end);
471
472 }
473
474 httpimg_find = findword(httpimg_find,fl_end,"_httpimg_");
475 }
476 format_here++;
477 }
478}
479
480text_t corbaproto::get_site_name () {
481 return site_name;
482}
483
484text_t corbaproto::get_protocol_name () {
485 return "corbaproto";
486}
487
488
489void corbaproto::get_collection_list (text_tarray &collist, comerror_t &err,
490 ostream &/*logout*/) {
491
492 // cout << "Corbaproto::Collection list" << endl;
493
494 corbatext_tarray corba_collist;
495 text_tarray tcollist;
496
497 // get the corba client reference
498 // corbaiface_var lclient = this->getCorbaClient(); // ****
499 corbaiface_var lclient = client;
500
501 // execute the corba transaction
502 lclient->collectionList(corba_collist);
503
504 // convert the response back to normal form
505 corbatext_corbaArrayToArray(corba_collist, &tcollist);
506 collist = tcollist;
507
508 err = noError;
509}
510
511void corbaproto::has_collection (const text_t &collection, bool &hascollection,
512 comerror_t &err, ostream &/*logout*/) {
513 // cout << "Corbaproto::Has collection" << endl;
514
515 corbatext_t corbaCollection;
516 corbaComError corbaError;
517 CORBA::Boolean corbaHas;
518
519 // get the corba client reference
520 // corbaiface_var lclient = this->getCorbaClient(); // ****
521 corbaiface_var lclient = client;
522
523 // convert all the requisite structures into their CORBA form
524 corbaconv_text_t::getCorbatext(collection,corbaCollection);
525
526 // execute the corba transaction
527 lclient->hasCollection(corbaCollection, corbaHas, corbaError);
528
529 // convert the response back to normal form
530 hascollection = (corbaHas != 0);
531 err = noError;
532}
533
534void corbaproto::ping (const text_t &collection, bool &wassuccess,
535 comerror_t &err, ostream &/*logout*/) {
536 // cout << "Corbaproto::Ping" << endl;
537
538 corbatext_t corbaCollect;
539 corbaComError corbaError;
540 bool success;
541
542 // get the corba client reference
543 // corbaiface_var lclient = this->getCorbaClient(); // ****
544 corbaiface_var lclient = client;
545
546 // convert all the requisite structures into their CORBA form
547 corbaconv_text_t::getCorbatext(collection,corbaCollect);
548
549 // execute the corba transaction
550 success = lclient->ping(corbaCollect, corbaError);
551
552 // convert the response back to normal form
553 wassuccess = (success != 0);
554}
555
556
557void corbaproto::get_collectinfo (const text_t &collection,
558 ColInfoResponse_t &collectinfo,
559 comerror_t &err, ostream &logout) {
560 // cout << "Corbaproto::Collectinfo" << endl;
561
562 corbatext_t corbaCollection;
563 corbaComError corbaError;
564 corbaColInfoResponse corbaCollectInfo;
565
566 // get the corba client reference
567 // corbaiface_var lclient = this->getCorbaClient(); // ****
568 corbaiface_var lclient = client;
569
570 // convert all the requisite structures into their CORBA form
571 corbaconv_text_t::getCorbatext(collection,corbaCollection);
572
573 // execute the corba transaction
574 lclient->getCollectInfo(corbaCollection, corbaCollectInfo, corbaError);
575
576 // convert the response back to normal form
577 collectinfo.isPublic = corbaCollectInfo.isPublic;
578 collectinfo.isBeta = corbaCollectInfo.isBeta;
579 collectinfo.buildDate = corbaCollectInfo.buildDate;
580 corbatext_corbaArrayToArray(corbaCollectInfo.ccsCols, &collectinfo.ccsCols);
581 corbatext_corbaArrayToArray(corbaCollectInfo.languages, &collectinfo.languages);
582 collectinfo.numDocs = corbaCollectInfo.numDocs;
583 collectinfo.numWords = corbaCollectInfo.numWords;
584 collectinfo.numBytes = corbaCollectInfo.numBytes;
585 corbatext_corbaMapToMap(corbaCollectInfo.collectionMeta, collectinfo.collectionmeta);
586 corbatext_corbaMapToMap(corbaCollectInfo.format, collectinfo.format);
587 corbatext_corbaMapToMap(corbaCollectInfo.building, collectinfo.building);
588 corbaconv_text_t::setCorbatext(collectinfo.httpdomain,corbaCollectInfo.httpdomain);
589 corbaconv_text_t::setCorbatext(collectinfo.httpprefix,corbaCollectInfo.httpprefix);
590 corbaconv_text_t::setCorbatext(collectinfo.receptionist,corbaCollectInfo.receptionist);
591
592 cache_missing_icons(collectinfo.format,collectinfo.httpdomain,
593 collectinfo.httpprefix);
594
595 err = (comerror_t) corbaError;
596}
597
598
599void corbaproto::get_filterinfo (const text_t &collection,
600 InfoFiltersResponse_t &response,
601 comerror_t &err, ostream &logout) {
602 // cout << "Corbaproto::Filterinfo" << endl;
603
604 corbatext_t corbaCollection;
605 corbatext_tset corbaResponse;
606 corbaComError corbaError;
607
608 // get the corba client reference
609 // corbaiface_var lclient = this->getCorbaClient(); // ****
610 corbaiface_var lclient = client;
611
612 // convert all the requisite structures into their CORBA form
613 corbaconv_text_t::getCorbatext(collection,corbaCollection);
614
615 // execute the corba transaction
616 lclient->getFilterInfo(corbaCollection, corbaResponse, corbaError);
617
618 // convert the response back to normal form
619 corbatext_corbaArrayToSet(corbaResponse, &response.filterNames);
620
621 err = (comerror_t) corbaError;
622}
623
624void corbaproto::get_filteroptions (const text_t &collection,
625 const InfoFilterOptionsRequest_t &request,
626 InfoFilterOptionsResponse_t &response,
627 comerror_t &err, ostream &logout) {
628 // cout << "Corbaproto::Filteroptions" << endl;
629
630 corbatext_t corbaCollection;
631 corbatext_t filterName;
632 corbaFilterOptionsResponse corbaResponse;
633 corbaComError corbaError;
634 unsigned int i;
635 corbaconv_text_t *cc_name;
636 FilterOption_t *option;
637
638 // get the corba client reference
639 // corbaiface_var lclient = this->getCorbaClient(); // ****
640 corbaiface_var lclient = client;
641
642 // convert all the requisite structures into their CORBA form
643 corbaconv_text_t::getCorbatext(collection,corbaCollection);
644 corbaconv_text_t::getCorbatext(request.filterName,filterName);
645
646 // execute the corba transaction
647 lclient->getFilterOptions(corbaCollection, filterName, corbaResponse, corbaError);
648
649 // convert the response back to normal form
650 for (i = 0; i < corbaResponse.names.length(); i ++)
651 {
652 cc_name = new corbaconv_text_t(corbaResponse.names[i]);
653
654 option = new FilterOption_t;
655 corbaconv_text_t::setCorbatext(option->name,corbaResponse.options[i].name);
656 option->type = (FilterOption_t::type_t) corbaResponse.options[i].type;
657 option->repeatable = (FilterOption_t::repeatable_t) corbaResponse.options[i].repeatable;
658 corbaconv_text_t::setCorbatext(option->defaultValue,corbaResponse.options[i].defaultValue);
659 corbatext_corbaArrayToArray(corbaResponse.options[i].validValues, &option->validValues);
660
661 response.filterOptions.insert(make_pair(*cc_name, *option)); // typecast to text_t
662 }
663
664 err = (comerror_t) corbaError;
665}
666
667
668void corbaproto::filter (const text_t &collection,
669 FilterRequest_t &request,
670 FilterResponse_t &response,
671 comerror_t &err, ostream &logout) {
672 // cout << "Corbaproto::Filter" << endl;
673
674 corbaFilterRequest corbaRequest;
675 corbaFilterResponse corbaResponse;
676 corbatext_t corbaCollection;
677 corbaComError corbaError;
678
679 // get the corba client reference
680 // corbaiface_var lclient = this->getCorbaClient(); // ****
681 corbaiface_var lclient = client;
682
683 // convert all the requisite structures into their CORBA form
684 corbaconv_text_t::getCorbatext(collection,corbaCollection);
685 corbaconv_text_t::getCorbatext(request.filterName,corbaRequest.filter);
686 corbatext_optionValueArrayToCorba(request.filterOptions, corbaRequest.filterOptions);
687 corbatext_arrayToCorbaArray(request.docSet, &corbaRequest.docSet);
688 corbaRequest.filterResultOptions = request.filterResultOptions;
689 corbaconv_text_t::getCorbatext(request.requestParams,corbaRequest.requestParams);
690 corbaconv_text_t::getCorbatext(request.refParams,corbaRequest.refParams);
691 corbaRequest.getParents = request.getParents;
692 corbatext_setToCorbaArray(request.fields, &corbaRequest.fields);
693
694 corbaResponse.numDocs = response.numDocs;
695 corbaresponse_resultDocInfoToCorba(response.docInfo, corbaResponse.docInfo);
696
697 // execute the corba transaction
698 lclient->filter (corbaCollection, corbaRequest, corbaResponse, corbaError);
699
700 // convert the response back to normal form
701 response.numDocs = corbaResponse.numDocs;
702 response.isApprox = corbaResponse.isApprox;
703 corbaresponse_resultDocInfoToC(corbaResponse.docInfo, response.docInfo);
704
705 // Added 31/1/2001, Michael Dewsnip
706 corbaresponse_resultTermInfoToC(corbaResponse.termInfo, response.termInfo);
707
708 err = (comerror_t) corbaError;
709 // cout << "Corbaproto::Filter" << endl;
710}
711
712
713void corbaproto::get_document (const text_t &collection,
714 const DocumentRequest_t &request,
715 DocumentResponse_t &response,
716 comerror_t &err, ostream &logout) {
717 // cout << "Corbaproto::Get Document" << endl;
718
719 corbatext_t corbaCollect;
720 corbaDocRequest corbaRequest;
721 corbaDocResponse corbaResponse;
722 corbaComError corbaError;
723
724 // get the corba client reference
725 // corbaiface_var lclient = this->getCorbaClient(); // ****
726 corbaiface_var lclient = client;
727
728 // convert all the requisite structures into their CORBA form
729 corbaconv_text_t::getCorbatext(collection,corbaCollect);
730 corbaconv_text_t::getCorbatext(request.OID,corbaRequest.OID);
731 corbaconv_text_t::getCorbatext(request.docType,corbaRequest.docType);
732 corbaconv_text_t::getCorbatext(request.docFormat,corbaRequest.docFormat);
733
734 // execute the corba transaction
735 lclient->getDocument(corbaCollect, corbaRequest, corbaResponse, corbaError);
736
737 // convert the response back to normal form
738 corbaconv_text_t::setCorbatext(response.doc,corbaResponse.doc);
739
740 err = (comerror_t) corbaError;
741}
742
Note: See TracBrowser for help on using the repository browser.