source: main/trunk/greenstone2/runtime-src/src/corba/corbaproto.mpp@ 25234

Last change on this file since 25234 was 25231, checked in by ak19, 12 years ago

Many changes to get corba working again ever since the addition of RSS support meant that the method get_rss_items needed to be mirrored in the corba code. The corba code was not compiling then and it turned out we needed a later version of Mico's corba implementation (2.3.13 up from 2.3.5). Therefore the current commit not only corrects some errors in the recently added getRssItems() method but includes further changes: 1. namespaced use of iostream functions were required in some mpp files. 2. New types and member variables added to the corbaiface.idl interface file, to mirror the presence of equivalent variables in comtools.h which hadn't been ported over yet. (Such as the complex corba data type equivalent of collectionmetamap used in comtools.h.) This required (de)serialisation methods to be declared and implemented in corbatext_t.h and corbatext_t.mpp. The additional member variables for the corbaColInfoResponse in corbaiface.idl are now also unpacked in corbaproto.mpp along with the rest of the data structure. 3. Having changed from mico version 2.3.5 to 2.3.13 required code to changed to use POA instead of BOA. This also meant that skeleton files were no longer to be generated when running idl over corbaiface.idl. corbaserver inherits from a POA related object now instead of from the skeleton. 4. Makefile.in was updated to reflect these changes (absence of skeleton), includes a target to run IDL over the corbaiface.idl file to generate the necessary helper files, and corrects earlier oversights in updating the corba makefile with the rest of the changes made over time to runtime-src.

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