[2126] | 1 | // Standard headers
|
---|
[1860] | 2 | #include <iostream.h>
|
---|
| 3 | #include <fstream.h>
|
---|
| 4 |
|
---|
| 5 | // protocol headers
|
---|
| 6 | #include "corbaiface.h"
|
---|
| 7 | using namespace gsdlInterface;
|
---|
| 8 |
|
---|
| 9 | #include "corbaconv_text_t.h"
|
---|
| 10 |
|
---|
| 11 | // library headers
|
---|
| 12 | #include "fileutil.h"
|
---|
| 13 | //#include "gsdlhome.h"
|
---|
| 14 |
|
---|
| 15 | // greenstone headers
|
---|
| 16 | #include "comtypes.h"
|
---|
| 17 | #include "recptproto.h"
|
---|
| 18 | #include "nullproto.h"
|
---|
| 19 |
|
---|
| 20 | // local headers
|
---|
| 21 | #include "corbatext_t.h"
|
---|
| 22 |
|
---|
| 23 | void corbatext_setToCorbaArray(text_tset set, corbatext_tset *cset);
|
---|
| 24 | void corbatext_corbaArrayToSet(corbatext_tset cset, text_tset *set);
|
---|
| 25 | void corbatext_mapToCorbaMap(text_tmap map, corbatext_tmap *tm);
|
---|
| 26 | void corbaresponse_resultDocInfoToCorba(ResultDocInfo_tarray docinfo, corbaResultDocInfo_array &corbainfo);
|
---|
| 27 |
|
---|
| 28 | void corbaresponse_termInfoToCorba(TermInfo_tarray terminfo, corbaTermInfo_array &corbainfo) {
|
---|
| 29 | TermInfo_tarray::iterator here = terminfo.begin();
|
---|
| 30 | TermInfo_tarray::iterator end = terminfo.end();
|
---|
| 31 | unsigned int i;
|
---|
| 32 |
|
---|
| 33 | i = 0;
|
---|
| 34 |
|
---|
| 35 | while (here != end)
|
---|
| 36 | {
|
---|
| 37 | corbainfo.length(i+1);
|
---|
| 38 |
|
---|
| 39 | corbainfo[i].frequency = here->freq;
|
---|
| 40 | corbaconv_text_t::getCorbatext(here->term,corbainfo[i].term);
|
---|
| 41 | corbatext_arrayToCorbaArray(here->matchTerms, &corbainfo[i].matchTerms);
|
---|
| 42 |
|
---|
| 43 | i ++;
|
---|
| 44 | here ++;
|
---|
| 45 | }
|
---|
| 46 | cout << "Terminfo " << i << endl;
|
---|
| 47 | }
|
---|
| 48 |
|
---|
| 49 | void corbatext_optionValueArrayToC(corbaOptionValue_array corba, OptionValue_tarray &array)
|
---|
| 50 | {
|
---|
| 51 | unsigned int i = 0;
|
---|
| 52 | OptionValue_t option;
|
---|
| 53 |
|
---|
| 54 | for (i = 0; i < corba.length(); i ++)
|
---|
| 55 | {
|
---|
| 56 | corbaconv_text_t::setCorbatext(option.name,corba[i].name);
|
---|
| 57 | corbaconv_text_t::setCorbatext(option.value,corba[i].value);
|
---|
| 58 |
|
---|
| 59 | // cout << corbatext_string(corba[i].name) << "?" << option
|
---|
| 60 |
|
---|
| 61 | array.push_back(option);
|
---|
| 62 | }
|
---|
| 63 | }
|
---|
| 64 |
|
---|
[2126] | 65 | class corbaServer : virtual public corbaiface_skel
|
---|
[1860] | 66 | {
|
---|
| 67 | private:
|
---|
| 68 | text_tarray collections;
|
---|
| 69 | recptproto *protocol;
|
---|
| 70 | text_t gsdlhome;
|
---|
| 71 |
|
---|
| 72 | void openLogfile(text_t extension, ofstream &out)
|
---|
| 73 | {
|
---|
| 74 | char *cfilename;
|
---|
| 75 | text_t filename;
|
---|
| 76 |
|
---|
| 77 | filename = filename_cat(gsdlhome, extension);
|
---|
| 78 | cfilename = filename.getcstr();
|
---|
| 79 |
|
---|
| 80 | out.open(cfilename);
|
---|
| 81 | delete cfilename;
|
---|
| 82 | }
|
---|
| 83 |
|
---|
| 84 | public:
|
---|
| 85 | corbaServer(recptproto *protocol, text_t home)
|
---|
| 86 | {
|
---|
| 87 | text_t dirname;
|
---|
| 88 | char * cdirname;
|
---|
| 89 |
|
---|
| 90 | cout << "CorbaServer: gsdlhome = " << home << endl;
|
---|
| 91 |
|
---|
| 92 | this->gsdlhome = home;
|
---|
| 93 | cout << gsdlhome.getcstr() << endl;
|
---|
| 94 | dirname = filename_cat(gsdlhome, "/collect");
|
---|
| 95 | cdirname = dirname.getcstr();
|
---|
[8186] | 96 | if (!read_dir (cdirname, collections)) {
|
---|
| 97 | cout << "Unable to read the gsdl directory; terminating" << endl;
|
---|
| 98 | exit (1);
|
---|
| 99 | }
|
---|
[1860] | 100 | delete cdirname;
|
---|
| 101 |
|
---|
| 102 | cout << "Constructing set list server" << endl;
|
---|
| 103 | this->protocol = protocol;
|
---|
[2126] | 104 |
|
---|
[1860] | 105 | }
|
---|
[2126] | 106 |
|
---|
| 107 | CORBA::Boolean initialise(corbaComError &err)
|
---|
[1860] | 108 | {
|
---|
[2113] | 109 | ofstream logout;
|
---|
| 110 | int reply;
|
---|
[2261] | 111 | comerror_t error = noError;
|
---|
[1860] | 112 |
|
---|
| 113 | this->openLogfile("/etc/corbaout.txt", logout);
|
---|
[2113] | 114 | reply = protocol->init(error, logout);
|
---|
[1860] | 115 | logout.close();
|
---|
| 116 | return (reply != 0 ? 1 : 0);
|
---|
| 117 | }
|
---|
| 118 |
|
---|
[2126] | 119 | void configure(const corbatext_t &corbaKey, const corbatext_tarray &corbaCfgline,corbaComError &err)
|
---|
[1860] | 120 | {
|
---|
[2113] | 121 | text_t key;
|
---|
| 122 | text_tarray cfgline;
|
---|
[2261] | 123 | comerror_t error = noError;
|
---|
[1860] | 124 |
|
---|
| 125 | corbaconv_text_t::setCorbatext(key,corbaKey);
|
---|
| 126 | corbatext_corbaArrayToArray(corbaCfgline, &cfgline);
|
---|
| 127 |
|
---|
| 128 |
|
---|
| 129 | // ****
|
---|
| 130 | cout << "Recieved " << key << " = ";
|
---|
[2113] | 131 | for (int unsigned i=0; i<cfgline.size(); i++)
|
---|
[1860] | 132 | {
|
---|
| 133 | cout << cfgline[i] << " ";
|
---|
| 134 | }
|
---|
| 135 | cout << endl;
|
---|
| 136 |
|
---|
| 137 | // DB // ****
|
---|
| 138 | if (key=="gsdlhome")
|
---|
| 139 | {
|
---|
| 140 | text_tarray cfgline;
|
---|
| 141 | cfgline.push_back (gsdlhome);
|
---|
| 142 | cout << "Changing gsdlhome to " << gsdlhome << endl;
|
---|
[2113] | 143 | protocol->configure(key, cfgline, error);
|
---|
[1860] | 144 | }
|
---|
| 145 | else if (key=="httpdomain")
|
---|
| 146 | {
|
---|
| 147 | // Only let gsdlhome through !!!! // ****
|
---|
| 148 | cout << "Supressing httpdomain" << endl;
|
---|
| 149 | }
|
---|
| 150 | else if (key=="httpprefix")
|
---|
| 151 | {
|
---|
| 152 | cout << "Supressing httpprefix" << endl;
|
---|
| 153 | }
|
---|
| 154 | else
|
---|
| 155 | {
|
---|
[2113] | 156 | protocol->configure(key, cfgline,error);
|
---|
[1860] | 157 | }
|
---|
| 158 | }
|
---|
| 159 |
|
---|
| 160 | void hasCollection(const corbatext_t &corbaCollect, CORBA::Boolean &has,
|
---|
| 161 | corbaComError &error) {
|
---|
| 162 | // do nowt!
|
---|
| 163 | corbaconv_text_t *cct;
|
---|
| 164 | bool _has;
|
---|
[2261] | 165 | comerror_t err = noError;
|
---|
[1860] | 166 | ofstream logout;
|
---|
| 167 |
|
---|
| 168 | this->openLogfile("/etc/corbaout.txt", logout);
|
---|
| 169 |
|
---|
| 170 | cct = new corbaconv_text_t(corbaCollect);
|
---|
| 171 |
|
---|
| 172 | cout << "Collection: " << cct->getcstr() << endl;
|
---|
| 173 |
|
---|
| 174 | protocol->has_collection(*cct, _has, err, logout); // 'cct' typecast to text_t
|
---|
| 175 | if (_has)
|
---|
| 176 | {
|
---|
| 177 | has = 1;
|
---|
| 178 | }
|
---|
| 179 | else
|
---|
| 180 | {
|
---|
| 181 | has = 0;
|
---|
| 182 | }
|
---|
| 183 |
|
---|
| 184 | // cout << " " << has << endl;
|
---|
| 185 |
|
---|
| 186 | delete cct;
|
---|
| 187 |
|
---|
| 188 | error = corbaNoError;
|
---|
| 189 | logout.close();
|
---|
| 190 | }
|
---|
| 191 |
|
---|
[2173] | 192 | void ping(const struct corbatext_t &corbaCollect, CORBA::Boolean &wasSuccess, corbaComError &corbaError)
|
---|
[1860] | 193 | {
|
---|
| 194 | text_t collection;
|
---|
| 195 | bool success;
|
---|
[2261] | 196 | comerror_t error = noError;
|
---|
[1860] | 197 | ofstream logout;
|
---|
| 198 |
|
---|
| 199 | this->openLogfile("/etc/corbaout.txt", logout);
|
---|
| 200 |
|
---|
| 201 | corbaconv_text_t::setCorbatext(collection,corbaCollect);
|
---|
| 202 | protocol->ping(collection, success, error, logout);
|
---|
| 203 |
|
---|
| 204 | corbaError = (corbaComError) error;
|
---|
[2173] | 205 | wasSuccess = (CORBA::Boolean) success;
|
---|
[1860] | 206 | logout.close();
|
---|
| 207 | }
|
---|
| 208 |
|
---|
| 209 | void filter(const struct corbatext_t &corbaCollect,
|
---|
| 210 | const struct corbaFilterRequest &corbaRequest,
|
---|
| 211 | struct corbaFilterResponse &corbaResponse,
|
---|
| 212 | corbaComError &corbaError)
|
---|
| 213 | {
|
---|
| 214 | // variables for action
|
---|
| 215 | FilterRequest_t request;
|
---|
| 216 | FilterResponse_t response;
|
---|
| 217 | comerror_t error = noError;
|
---|
| 218 | text_t collection;
|
---|
| 219 | ofstream logout;
|
---|
| 220 |
|
---|
| 221 | this->openLogfile("/etc/corbaout.txt", logout);
|
---|
| 222 |
|
---|
| 223 | // copy collection id
|
---|
| 224 | corbaconv_text_t::setCorbatext(collection,corbaCollect);
|
---|
| 225 |
|
---|
| 226 | // copy request values
|
---|
| 227 | corbaconv_text_t::setCorbatext(request.filterName,corbaRequest.filter);
|
---|
| 228 | corbatext_optionValueArrayToC(corbaRequest.filterOptions, request.filterOptions);
|
---|
| 229 | corbatext_corbaArrayToArray(corbaRequest.docSet, &request.docSet);
|
---|
| 230 | request.filterResultOptions = corbaRequest.filterResultOptions;
|
---|
| 231 | corbaconv_text_t::setCorbatext(request.requestParams,corbaRequest.requestParams);
|
---|
| 232 | corbaconv_text_t::setCorbatext(request.refParams,corbaRequest.refParams);
|
---|
| 233 | corbatext_corbaArrayToSet(corbaRequest.fields, &request.fields);
|
---|
| 234 | request.getParents = corbaRequest.getParents;
|
---|
| 235 |
|
---|
| 236 | protocol->filter(collection, request, response, error, logout);
|
---|
| 237 |
|
---|
| 238 | // copy response values
|
---|
| 239 | corbaResponse.numDocs = response.numDocs;
|
---|
[2113] | 240 | corbaResponse.isApprox = (::gsdlInterface::corbaIsApprox) response.isApprox;
|
---|
[1860] | 241 | corbaresponse_termInfoToCorba(response.termInfo, corbaResponse.termInfo);
|
---|
| 242 | corbaresponse_resultDocInfoToCorba(response.docInfo, corbaResponse.docInfo);
|
---|
| 243 |
|
---|
| 244 | // tidy up variables
|
---|
| 245 | logout.close();
|
---|
| 246 | corbaError = (corbaComError) error;
|
---|
| 247 | cout << "Filter prepared" << corbaResponse.docInfo.length() << "," << corbaResponse.numDocs << endl;
|
---|
| 248 | }
|
---|
| 249 |
|
---|
| 250 | void getCollectInfo(const struct corbatext_t &corbaCollect,
|
---|
| 251 | corbaColInfoResponse &corbaResponse,
|
---|
| 252 | corbaComError &corbaError)
|
---|
| 253 | {
|
---|
| 254 | ColInfoResponse_t response;
|
---|
[2261] | 255 | comerror_t error = noError;
|
---|
[1860] | 256 | text_t collection;
|
---|
| 257 | ofstream logout;
|
---|
| 258 |
|
---|
| 259 | this->openLogfile("/etc/corbaout.txt", logout);
|
---|
| 260 |
|
---|
| 261 | corbaconv_text_t::setCorbatext(collection,corbaCollect);
|
---|
| 262 | protocol->get_collectinfo(collection, response, error, logout);
|
---|
| 263 |
|
---|
| 264 | cout << "IsPublic = " << ((response.isPublic)?"True":"False") << endl;
|
---|
| 265 | cout << "IsBeta = " << ((response.isBeta) ?"True":"False") << endl;
|
---|
| 266 | cout << "BuildDate = " << response.buildDate << endl;
|
---|
| 267 | cout << "NumDocs = " << response.numDocs << endl;
|
---|
| 268 | cout << "NumBytes = " << response.numBytes << endl;
|
---|
| 269 | cout << "NumWords = " << response.numWords << endl;
|
---|
[13982] | 270 | cout << "UseBook = " << ((response.useBook) ?"True":"False") << endl;
|
---|
| 271 |
|
---|
| 272 | corbaResponse.useBook = response.useBook;
|
---|
[2174] | 273 | corbaResponse.isPublic = response.isPublic;
|
---|
| 274 | corbaResponse.isBeta = response.isBeta;
|
---|
[1860] | 275 | corbaResponse.buildDate = response.buildDate;
|
---|
| 276 | corbatext_arrayToCorbaArray(response.languages, &corbaResponse.languages);
|
---|
| 277 | corbatext_arrayToCorbaArray(response.ccsCols, &corbaResponse.ccsCols);
|
---|
[2174] | 278 | corbaResponse.numDocs = response.numDocs;
|
---|
| 279 | corbaResponse.numBytes = response.numBytes;
|
---|
| 280 | corbaResponse.numWords = response.numWords;
|
---|
[1860] | 281 |
|
---|
| 282 | corbatext_mapToCorbaMap(response.collectionmeta, &corbaResponse.collectionMeta);
|
---|
| 283 | corbatext_mapToCorbaMap(response.format, &corbaResponse.format);
|
---|
| 284 | corbatext_mapToCorbaMap(response.building, &corbaResponse.building);
|
---|
| 285 | corbaconv_text_t::getCorbatext(response.httpdomain,corbaResponse.httpdomain);
|
---|
| 286 |
|
---|
| 287 | corbaconv_text_t::getCorbatext(response.httpprefix,corbaResponse.httpprefix);
|
---|
| 288 | corbaconv_text_t::getCorbatext(response.receptionist,corbaResponse.receptionist);
|
---|
| 289 |
|
---|
| 290 | /* text_tmap::iterator f_here = response.format.begin();
|
---|
| 291 | text_tmap::iterator f_end = response.format.end();
|
---|
| 292 | while (f_here!=f_end)
|
---|
| 293 | {
|
---|
| 294 | cout << "**** format: " << f_here->first << " = " << f_here->second << endl;
|
---|
| 295 | f_here++;
|
---|
| 296 | }
|
---|
| 297 | */ // ****
|
---|
| 298 |
|
---|
| 299 | logout.close();
|
---|
| 300 | corbaError = (corbaComError) error;
|
---|
| 301 | }
|
---|
| 302 |
|
---|
| 303 | void getFilterOptions(const struct corbatext_t &corbaCollect,
|
---|
| 304 | const struct corbatext_t &corbaFilterName,
|
---|
| 305 | struct corbaFilterOptionsResponse &corbaResponse,
|
---|
| 306 | enum corbaComError &corbaError)
|
---|
| 307 | {
|
---|
| 308 | text_t collection;
|
---|
| 309 | InfoFilterOptionsRequest_t request;
|
---|
| 310 | InfoFilterOptionsResponse_t response;
|
---|
[2261] | 311 | comerror_t error = noError;
|
---|
[1860] | 312 | unsigned int i;
|
---|
| 313 | ofstream logout;
|
---|
| 314 |
|
---|
| 315 | this->openLogfile("/etc/corbaout.txt", logout);
|
---|
| 316 |
|
---|
| 317 | corbaconv_text_t::setCorbatext(collection,corbaCollect);
|
---|
| 318 | corbaconv_text_t::setCorbatext(request.filterName,corbaFilterName);
|
---|
| 319 | protocol->get_filteroptions(collection, request, response, error, logout);
|
---|
| 320 |
|
---|
| 321 | // decode filters back into corba format
|
---|
| 322 | FilterOption_tmap::iterator here = response.filterOptions.begin();
|
---|
| 323 | FilterOption_tmap::iterator end = response.filterOptions.end();
|
---|
| 324 | i = 0;
|
---|
| 325 | while (here != end)
|
---|
| 326 | {
|
---|
| 327 | // set array for name/options to be one bigger
|
---|
| 328 | corbaResponse.names.length(i+1);
|
---|
| 329 | corbaResponse.options.length(i+1);
|
---|
| 330 |
|
---|
| 331 | // get left-hand side of map
|
---|
| 332 | corbaconv_text_t::getCorbatext((*here).first,corbaResponse.names[i]);
|
---|
| 333 |
|
---|
| 334 | // get right-hand side of map
|
---|
| 335 | corbaconv_text_t::getCorbatext((*here).second.name,corbaResponse.options[i].name);
|
---|
[2113] | 336 | corbaResponse.options[i].type =
|
---|
| 337 | (::gsdlInterface::corbaFilterType)(*here).second.type;
|
---|
| 338 | corbaResponse.options[i].repeatable =
|
---|
| 339 | (::gsdlInterface::corbaFilterRepeatable)(*here).second.repeatable;
|
---|
[1860] | 340 | corbaconv_text_t::getCorbatext((*here).second.defaultValue,corbaResponse.options[i].defaultValue);
|
---|
| 341 | corbatext_arrayToCorbaArray((*here).second.validValues, &corbaResponse.options[i].validValues);
|
---|
| 342 |
|
---|
| 343 | // take next iterators
|
---|
| 344 | i++;
|
---|
| 345 | here ++;
|
---|
| 346 | }
|
---|
| 347 |
|
---|
| 348 | logout.close();
|
---|
| 349 | corbaError = (corbaComError) error;
|
---|
| 350 | }
|
---|
| 351 |
|
---|
| 352 | void getFilterInfo(const struct corbatext_t &corbaCollect,
|
---|
| 353 | corbatext_tarray &filterNames,
|
---|
| 354 | enum corbaComError &corbaError)
|
---|
| 355 | { text_tarray ta;
|
---|
| 356 | comerror_t error = noError;
|
---|
| 357 | text_t collection;
|
---|
| 358 | InfoFiltersResponse_t response;
|
---|
| 359 | ofstream logout;
|
---|
| 360 |
|
---|
| 361 | this->openLogfile("/etc/corbaout.txt", logout);
|
---|
| 362 |
|
---|
| 363 | corbaconv_text_t::setCorbatext(collection,corbaCollect);
|
---|
| 364 | cout << collection.getcstr() << endl;
|
---|
| 365 |
|
---|
| 366 | protocol->get_filterinfo(collection, response, error, logout);
|
---|
| 367 | corbatext_setToCorbaArray(response.filterNames, &filterNames);
|
---|
| 368 |
|
---|
| 369 | corbaError = (corbaComError) error;
|
---|
| 370 | logout.close();
|
---|
| 371 | }
|
---|
| 372 |
|
---|
| 373 | void getDocument(const struct corbatext_t &corbaCollection, struct corbaDocRequest &corbaRequest,
|
---|
| 374 | struct corbaDocResponse &corbaResponse, enum corbaComError &corbaError)
|
---|
| 375 | { DocumentRequest_t request;
|
---|
| 376 | DocumentResponse_t response;
|
---|
| 377 | comerror_t error = noError;
|
---|
| 378 | text_t collection;
|
---|
| 379 | ofstream logout;
|
---|
| 380 |
|
---|
| 381 | this->openLogfile("/etc/corbaout.txt", logout);
|
---|
| 382 |
|
---|
| 383 | // set up request
|
---|
| 384 | corbaconv_text_t::setCorbatext(collection,corbaCollection);
|
---|
| 385 | corbaconv_text_t::setCorbatext(request.OID,corbaRequest.OID);
|
---|
| 386 | corbaconv_text_t::setCorbatext(request.docType,corbaRequest.docType);
|
---|
| 387 | corbaconv_text_t::setCorbatext(request.docFormat,corbaRequest.docFormat);
|
---|
| 388 |
|
---|
| 389 | // do actual get document
|
---|
| 390 | protocol->get_document(collection, request, response, error, logout);
|
---|
| 391 | corbaconv_text_t::getCorbatext(response.doc,corbaResponse.doc);
|
---|
| 392 |
|
---|
| 393 | // decode response
|
---|
| 394 | corbaError = (corbaComError) error;
|
---|
| 395 |
|
---|
| 396 | logout.close();
|
---|
| 397 | }
|
---|
| 398 |
|
---|
[24959] | 399 | void getRssItems (const struct corbatext_t &corbaCollect,
|
---|
| 400 | const struct corbatext_t &corbaGsdlHome,
|
---|
| 401 | const struct corbatext_t &corbaRssItems,
|
---|
| 402 | enum corbaComError &corbaError)
|
---|
| 403 | {
|
---|
| 404 | text_t collection;
|
---|
| 405 | text_t gsdlhome;
|
---|
| 406 | text_t rss_items;
|
---|
| 407 | comerror_t error = noError;
|
---|
| 408 | ofstream logout;
|
---|
| 409 |
|
---|
| 410 | this->openLogfile("/etc/corbaout.txt", logout);
|
---|
| 411 |
|
---|
| 412 | corbaconv_text_t::setCorbatext(collection,corbaCollect);
|
---|
| 413 | corbaconv_text_t::setCorbatext(gsdlhome,corbaGsdlHome);
|
---|
| 414 |
|
---|
| 415 | // do actual operation
|
---|
| 416 | protocol->get_rss_items(collection, gsdlhome, rss_items, error, logout);
|
---|
| 417 | corbaconv_text_t::getCorbatext(rss_items,corbaRssItems);
|
---|
| 418 |
|
---|
| 419 | // decode response
|
---|
| 420 | corbaError = (corbaComError) error;
|
---|
| 421 |
|
---|
| 422 | logout.close();
|
---|
| 423 | }
|
---|
| 424 |
|
---|
[2126] | 425 | void collectionList(corbatext_tarray &corbalist, corbaComError &error)
|
---|
[1860] | 426 | {
|
---|
| 427 | /* stringSeq *reply;
|
---|
| 428 | unsigned int i;
|
---|
| 429 | char *istring; */
|
---|
| 430 |
|
---|
| 431 | text_tarray collist;
|
---|
| 432 | comerror_t err;
|
---|
| 433 | ofstream logout;
|
---|
| 434 |
|
---|
| 435 | cout << "Received collection list request" << endl;
|
---|
| 436 |
|
---|
| 437 | this->openLogfile("/etc/corbaout.txt", logout);
|
---|
| 438 |
|
---|
| 439 | protocol->get_collection_list(collist, err, logout);
|
---|
| 440 |
|
---|
| 441 | /* reply = new stringSeq(collections.size());
|
---|
| 442 |
|
---|
| 443 | (*reply).length(collections.size());
|
---|
| 444 | for (i = 0; i < collections.size(); i ++)
|
---|
| 445 | {
|
---|
| 446 | istring = collections[i].getcstr();
|
---|
| 447 | (*reply)[i] = CORBA::string_dup(istring);
|
---|
| 448 | delete istring;
|
---|
| 449 | }
|
---|
| 450 |
|
---|
| 451 | return reply;
|
---|
| 452 | */
|
---|
| 453 |
|
---|
| 454 | corbatext_arrayToCorbaArray(collist, &corbalist);
|
---|
| 455 | cout << "Replying " << collist.size() << ": " << endl;
|
---|
| 456 |
|
---|
[2113] | 457 | for (int unsigned i = 0; i < collist.size(); i ++)
|
---|
[1860] | 458 | {
|
---|
| 459 | cout << collist[i];
|
---|
| 460 | if (i<collist.size()-1) cout << ", ";
|
---|
| 461 | }
|
---|
| 462 | cout << endl;
|
---|
| 463 |
|
---|
| 464 | logout.close();
|
---|
| 465 | // CORBA::string_dup(_listString);
|
---|
| 466 | }
|
---|
| 467 | };
|
---|
| 468 |
|
---|
| 469 | int main (int argc, char *argv[])
|
---|
| 470 | {
|
---|
| 471 | nullproto protocol;
|
---|
| 472 | collectset *cservers;
|
---|
| 473 | text_t gsdlhome;
|
---|
| 474 |
|
---|
| 475 | cservers = new collectset(gsdlhome);
|
---|
| 476 | protocol.set_collectset(cservers);
|
---|
| 477 |
|
---|
| 478 | cout << "Started Corba ..." << endl;
|
---|
| 479 |
|
---|
| 480 | // ORB initialization
|
---|
| 481 | CORBA::ORB_var orb = CORBA::ORB_init( argc, argv, "mico-local-orb" );
|
---|
| 482 | CORBA::BOA_var boa = orb->BOA_init( argc, argv, "mico-local-boa" );
|
---|
| 483 |
|
---|
| 484 | cout << "Initialised ORB and BOA" << endl;
|
---|
| 485 |
|
---|
| 486 | corbaServer* server = new corbaServer(&protocol, gsdlhome);
|
---|
[2126] | 487 |
|
---|
| 488 | cout << "Initialised server" << endl;
|
---|
| 489 |
|
---|
[1860] | 490 | CORBA::String_var ref = orb->object_to_string( server );
|
---|
| 491 |
|
---|
| 492 | cout << "Mapped Corba object to string" << endl;
|
---|
| 493 |
|
---|
| 494 | // write id to "naming service"
|
---|
| 495 | ofstream out ("/tmp/localcorba.objid");
|
---|
[3061] | 496 | if (out.is_open()) {
|
---|
| 497 | out << ref << endl;
|
---|
| 498 | if (out.fail() || out.bad()) {
|
---|
| 499 | cout << "Failed " << endl;
|
---|
| 500 | }
|
---|
| 501 | out.close ();
|
---|
| 502 | }
|
---|
| 503 | else {
|
---|
| 504 | cout << "Unable to write string to file /tmp/localcorba.objid" << endl;
|
---|
| 505 | cout << "Please check the file permissions/ownership" << endl;
|
---|
| 506 | return 0;
|
---|
| 507 | }
|
---|
[1860] | 508 | cout << "Corba string is " << ref << endl;
|
---|
| 509 |
|
---|
| 510 | // indicate readiness and run
|
---|
| 511 | boa->impl_is_ready( CORBA::ImplementationDef::_nil() );
|
---|
| 512 | orb->run ();
|
---|
| 513 | CORBA::release( server );
|
---|
| 514 | return 0;
|
---|
| 515 | }
|
---|
| 516 |
|
---|
| 517 |
|
---|