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 15471 2008-05-15 00:05:45Z mdewsnip $
|
---|
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"
|
---|
35 | using 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 |
|
---|
49 | void 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 |
|
---|
68 | void 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 |
|
---|
75 | void 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 |
|
---|
82 | int 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 |
|
---|
106 | MetadataInfo_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 |
|
---|
130 | void 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 |
|
---|
208 | void 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
|
---|
282 | void 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 |
|
---|
302 | corbaproto::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 |
|
---|
332 | corbaiface_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
|
---|
371 | void 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 = corbaNoError;
|
---|
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
|
---|
404 | bool corbaproto::init (comerror_t &err, ostream &logout) {
|
---|
405 | // cout << "Corbaproto::Init" << endl;
|
---|
406 | gsdlInterface::corbaComError error = corbaNoError;
|
---|
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 |
|
---|
416 | void 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 |
|
---|
484 | text_t corbaproto::get_site_name (comerror_t &err) {
|
---|
485 | return site_name;
|
---|
486 | }
|
---|
487 |
|
---|
488 | text_t corbaproto::get_protocol_name (comerror_t &err) {
|
---|
489 | return "corbaproto";
|
---|
490 | }
|
---|
491 |
|
---|
492 |
|
---|
493 | void 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 = corbaNoError;
|
---|
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 |
|
---|
516 | void 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 = corbaNoError;
|
---|
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 |
|
---|
539 | void 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 = corbaNoError;
|
---|
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 | err = (comerror_t) corbaError;
|
---|
560 | cout << "Corbaproto::Ping" << err << endl;
|
---|
561 | }
|
---|
562 |
|
---|
563 |
|
---|
564 | void 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 = corbaNoError;
|
---|
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.useBook = corbaCollectInfo.useBook;
|
---|
585 | collectinfo.isPublic = corbaCollectInfo.isPublic;
|
---|
586 | collectinfo.isBeta = corbaCollectInfo.isBeta;
|
---|
587 | collectinfo.buildDate = corbaCollectInfo.buildDate;
|
---|
588 | corbatext_corbaArrayToArray(corbaCollectInfo.ccsCols, &collectinfo.ccsCols);
|
---|
589 | corbatext_corbaArrayToArray(corbaCollectInfo.languages, &collectinfo.languages);
|
---|
590 | collectinfo.numDocs = corbaCollectInfo.numDocs;
|
---|
591 | collectinfo.numWords = corbaCollectInfo.numWords;
|
---|
592 | collectinfo.numBytes = corbaCollectInfo.numBytes;
|
---|
593 | corbatext_corbaMapToMap(corbaCollectInfo.collectionMeta, collectinfo.collectionmeta);
|
---|
594 | corbatext_corbaMapToMap(corbaCollectInfo.format, collectinfo.format);
|
---|
595 | corbatext_corbaMapToMap(corbaCollectInfo.building, collectinfo.building);
|
---|
596 | corbaconv_text_t::setCorbatext(collectinfo.httpdomain,corbaCollectInfo.httpdomain);
|
---|
597 | corbaconv_text_t::setCorbatext(collectinfo.httpprefix,corbaCollectInfo.httpprefix);
|
---|
598 | corbaconv_text_t::setCorbatext(collectinfo.receptionist,corbaCollectInfo.receptionist);
|
---|
599 |
|
---|
600 | cache_missing_icons(collectinfo.format,collectinfo.httpdomain,
|
---|
601 | collectinfo.httpprefix);
|
---|
602 |
|
---|
603 | err = (comerror_t) corbaError;
|
---|
604 | }
|
---|
605 |
|
---|
606 |
|
---|
607 | void corbaproto::get_filterinfo (const text_t &collection,
|
---|
608 | InfoFiltersResponse_t &response,
|
---|
609 | comerror_t &err, ostream &logout) {
|
---|
610 | // cout << "Corbaproto::Filterinfo" << endl;
|
---|
611 |
|
---|
612 | corbatext_t corbaCollection;
|
---|
613 | corbatext_tset corbaResponse;
|
---|
614 | corbaComError corbaError = corbaNoError;
|
---|
615 |
|
---|
616 | // get the corba client reference
|
---|
617 | // corbaiface_var lclient = this->getCorbaClient(); // ****
|
---|
618 | corbaiface_var lclient = client;
|
---|
619 |
|
---|
620 | // convert all the requisite structures into their CORBA form
|
---|
621 | corbaconv_text_t::getCorbatext(collection,corbaCollection);
|
---|
622 |
|
---|
623 | // execute the corba transaction
|
---|
624 | lclient->getFilterInfo(corbaCollection, corbaResponse, corbaError);
|
---|
625 |
|
---|
626 | // convert the response back to normal form
|
---|
627 | corbatext_corbaArrayToSet(corbaResponse, &response.filterNames);
|
---|
628 |
|
---|
629 | err = (comerror_t) corbaError;
|
---|
630 | }
|
---|
631 |
|
---|
632 | void corbaproto::get_filteroptions (const text_t &collection,
|
---|
633 | const InfoFilterOptionsRequest_t &request,
|
---|
634 | InfoFilterOptionsResponse_t &response,
|
---|
635 | comerror_t &err, ostream &logout) {
|
---|
636 | // cout << "Corbaproto::Filteroptions" << endl;
|
---|
637 |
|
---|
638 | corbatext_t corbaCollection;
|
---|
639 | corbatext_t filterName;
|
---|
640 | corbaFilterOptionsResponse corbaResponse;
|
---|
641 | corbaComError corbaError = corbaNoError;
|
---|
642 | unsigned int i;
|
---|
643 | corbaconv_text_t *cc_name;
|
---|
644 | FilterOption_t *option;
|
---|
645 |
|
---|
646 | // get the corba client reference
|
---|
647 | // corbaiface_var lclient = this->getCorbaClient(); // ****
|
---|
648 | corbaiface_var lclient = client;
|
---|
649 |
|
---|
650 | // convert all the requisite structures into their CORBA form
|
---|
651 | corbaconv_text_t::getCorbatext(collection,corbaCollection);
|
---|
652 | corbaconv_text_t::getCorbatext(request.filterName,filterName);
|
---|
653 |
|
---|
654 | // execute the corba transaction
|
---|
655 | lclient->getFilterOptions(corbaCollection, filterName, corbaResponse, corbaError);
|
---|
656 |
|
---|
657 | // convert the response back to normal form
|
---|
658 | for (i = 0; i < corbaResponse.names.length(); i ++)
|
---|
659 | {
|
---|
660 | cc_name = new corbaconv_text_t(corbaResponse.names[i]);
|
---|
661 |
|
---|
662 | option = new FilterOption_t;
|
---|
663 | corbaconv_text_t::setCorbatext(option->name,corbaResponse.options[i].name);
|
---|
664 | option->type = (FilterOption_t::type_t) corbaResponse.options[i].type;
|
---|
665 | option->repeatable = (FilterOption_t::repeatable_t) corbaResponse.options[i].repeatable;
|
---|
666 | corbaconv_text_t::setCorbatext(option->defaultValue,corbaResponse.options[i].defaultValue);
|
---|
667 | corbatext_corbaArrayToArray(corbaResponse.options[i].validValues, &option->validValues);
|
---|
668 |
|
---|
669 | response.filterOptions.insert(make_pair(*cc_name, *option)); // typecast to text_t
|
---|
670 | }
|
---|
671 |
|
---|
672 | err = (comerror_t) corbaError;
|
---|
673 | }
|
---|
674 |
|
---|
675 |
|
---|
676 | void corbaproto::filter (const text_t &collection,
|
---|
677 | FilterRequest_t &request,
|
---|
678 | FilterResponse_t &response,
|
---|
679 | comerror_t &err, ostream &logout) {
|
---|
680 | // cout << "Corbaproto::Filter" << endl;
|
---|
681 |
|
---|
682 | corbaFilterRequest corbaRequest;
|
---|
683 | corbaFilterResponse corbaResponse;
|
---|
684 | corbatext_t corbaCollection;
|
---|
685 | corbaComError corbaError = corbaNoError;
|
---|
686 |
|
---|
687 | // get the corba client reference
|
---|
688 | // corbaiface_var lclient = this->getCorbaClient(); // ****
|
---|
689 | corbaiface_var lclient = client;
|
---|
690 |
|
---|
691 | // convert all the requisite structures into their CORBA form
|
---|
692 | corbaconv_text_t::getCorbatext(collection,corbaCollection);
|
---|
693 | corbaconv_text_t::getCorbatext(request.filterName,corbaRequest.filter);
|
---|
694 | corbatext_optionValueArrayToCorba(request.filterOptions, corbaRequest.filterOptions);
|
---|
695 | corbatext_arrayToCorbaArray(request.docSet, &corbaRequest.docSet);
|
---|
696 | corbaRequest.filterResultOptions = request.filterResultOptions;
|
---|
697 | corbaconv_text_t::getCorbatext(request.requestParams,corbaRequest.requestParams);
|
---|
698 | corbaconv_text_t::getCorbatext(request.refParams,corbaRequest.refParams);
|
---|
699 | corbaRequest.getParents = request.getParents;
|
---|
700 | corbatext_setToCorbaArray(request.fields, &corbaRequest.fields);
|
---|
701 |
|
---|
702 | corbaResponse.numDocs = response.numDocs;
|
---|
703 | corbaresponse_resultDocInfoToCorba(response.docInfo, corbaResponse.docInfo);
|
---|
704 |
|
---|
705 | // execute the corba transaction
|
---|
706 | lclient->filter (corbaCollection, corbaRequest, corbaResponse, corbaError);
|
---|
707 |
|
---|
708 | // convert the response back to normal form
|
---|
709 | response.numDocs = corbaResponse.numDocs;
|
---|
710 | response.isApprox = (enum isapprox) corbaResponse.isApprox;
|
---|
711 | corbaresponse_resultDocInfoToC(corbaResponse.docInfo, response.docInfo);
|
---|
712 |
|
---|
713 | // Added 31/1/2001, Michael Dewsnip
|
---|
714 | corbaresponse_resultTermInfoToC(corbaResponse.termInfo, response.termInfo);
|
---|
715 |
|
---|
716 | err = (comerror_t) corbaError;
|
---|
717 | // cout << "Corbaproto::Filter" << endl;
|
---|
718 | }
|
---|
719 |
|
---|
720 |
|
---|
721 | void corbaproto::get_document (const text_t &collection,
|
---|
722 | const DocumentRequest_t &request,
|
---|
723 | DocumentResponse_t &response,
|
---|
724 | comerror_t &err, ostream &logout) {
|
---|
725 | // cout << "Corbaproto::Get Document" << endl;
|
---|
726 |
|
---|
727 | corbatext_t corbaCollect;
|
---|
728 | corbaDocRequest corbaRequest;
|
---|
729 | corbaDocResponse corbaResponse;
|
---|
730 | corbaComError corbaError = corbaNoError;
|
---|
731 |
|
---|
732 | // get the corba client reference
|
---|
733 | // corbaiface_var lclient = this->getCorbaClient(); // ****
|
---|
734 | corbaiface_var lclient = client;
|
---|
735 |
|
---|
736 | // convert all the requisite structures into their CORBA form
|
---|
737 | corbaconv_text_t::getCorbatext(collection,corbaCollect);
|
---|
738 | corbaconv_text_t::getCorbatext(request.OID,corbaRequest.OID);
|
---|
739 | corbaconv_text_t::getCorbatext(request.docType,corbaRequest.docType);
|
---|
740 | corbaconv_text_t::getCorbatext(request.docFormat,corbaRequest.docFormat);
|
---|
741 |
|
---|
742 | // execute the corba transaction
|
---|
743 | lclient->getDocument(corbaCollect, corbaRequest, corbaResponse, corbaError);
|
---|
744 |
|
---|
745 | // convert the response back to normal form
|
---|
746 | corbaconv_text_t::setCorbatext(response.doc,corbaResponse.doc);
|
---|
747 |
|
---|
748 | err = (comerror_t) corbaError;
|
---|
749 | }
|
---|
750 |
|
---|