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

Last change on this file since 2122 was 2122, checked in by say1, 23 years ago

(more) corba fixes. hopefully now compiles directly from the box ...

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