Changeset 15002
- Timestamp:
- 2008-02-22T11:25:40+13:00 (16 years ago)
- Location:
- gsdl/trunk/src
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
gsdl/trunk/src/colservr/collectserver.cpp
r13982 r15002 98 98 if (value == "true") collectinfo.isBeta = true; 99 99 else collectinfo.isBeta = false; 100 } else if (key == "collectgroup") { 101 if (value == "true") collectinfo.isCollectGroup = true; 102 else collectinfo.isCollectGroup = false; 100 103 } else if ((key == "ccscols") || (key == "supercollection")) collectinfo.ccsCols = cfgline; 101 104 else if (key == "supercollectionoptions") { -
gsdl/trunk/src/colservr/collectserver.h
r9929 r15002 101 101 const colservrconf &get_configinfo () {return configinfo;} 102 102 text_t get_collection_name () {return configinfo.collection;} 103 bool is_collection_group () {return collectinfo.isCollectGroup;} 104 103 105 104 106 // ping indicates whether the collection has appropriate data structures -
gsdl/trunk/src/colservr/collectset.cpp
r12246 r15002 51 51 // get gsdlhome (if we fail the error will be picked up later -- in 52 52 // cgiwrapper) 53 53 54 if (site_cfg_read (gsdlhome, httpdomain, httpprefix)) { 54 55 if (!gsdlhome.empty() && directory_exists(gsdlhome)) { … … 66 67 } 67 68 68 // read config file to see if built with mg, mgpp, or lucene 69 text_t buildtype = "mg"; // mg is default 70 text_tarray cfgline; 71 text_t key; 72 text_t filename = filename_cat(collectdir, *thiscol, "index" , "build.cfg"); 73 ifstream confin(filename.getcstr()); 74 75 if (confin) { 76 while (read_cfg_line(confin, cfgline) >= 0) { 77 if (cfgline.size() ==2 ) { 78 key = cfgline[0]; 79 cfgline.erase(cfgline.begin()); 80 if (key =="buildtype") { 81 buildtype = cfgline[0]; 82 break; 83 } 84 } 85 } 86 } 87 88 confin.close(); 89 90 // this memory is created but never destroyed 91 // we're also not doing any error checking to make sure we didn't 92 // run out of memory 93 collectserver *cserver = new collectserver(); 94 gdbmclass *gdbmhandler = new gdbmclass(); 95 96 // add a null filter 97 filterclass *filter = new filterclass (); 98 cserver->add_filter (filter); 99 100 // add a browse filter 101 browsefilterclass *browsefilter = new browsefilterclass(); 102 browsefilter->set_gdbmptr (gdbmhandler); 103 cserver->add_filter (browsefilter); 104 105 if (buildtype == "mg") { 106 mgsearch = new mgsearchclass(); 107 108 // add a query filter 109 mgqueryfilterclass *queryfilter = new mgqueryfilterclass(); 110 queryfilter->set_gdbmptr (gdbmhandler); 111 queryfilter->set_textsearchptr (mgsearch); 112 cserver->add_filter (queryfilter); 113 114 // add a mg and gdbm source 115 mggdbmsourceclass *mggdbmsource = new mggdbmsourceclass (); 116 mggdbmsource->set_gdbmptr (gdbmhandler); 117 mggdbmsource->set_textsearchptr (mgsearch); 118 cserver->add_source (mggdbmsource); 119 120 } 121 else if (buildtype == "mgpp") { 122 123 mgppsearch = new mgppsearchclass(); 124 125 // add a query filter 126 mgppqueryfilterclass *queryfilter = new mgppqueryfilterclass(); 127 queryfilter->set_gdbmptr (gdbmhandler); 128 queryfilter->set_textsearchptr (mgppsearch); 129 cserver->add_filter (queryfilter); 130 131 // add a mg and gdbm source 132 mggdbmsourceclass *mggdbmsource = new mggdbmsourceclass (); 133 mggdbmsource->set_gdbmptr (gdbmhandler); 134 mggdbmsource->set_textsearchptr (mgppsearch); 135 cserver->add_source (mggdbmsource); 136 } 137 else if (buildtype == "lucene") { 138 lucenesearch = new lucenesearchclass(); 139 lucenesearch->set_gsdlhome(gsdlhome); 140 141 // add a query filter 142 lucenequeryfilterclass *queryfilter = new lucenequeryfilterclass(); 143 queryfilter->set_gdbmptr (gdbmhandler); 144 queryfilter->set_textsearchptr (lucenesearch); 145 cserver->add_filter (queryfilter); 146 147 // add a lucene and gdbm source 148 lucenegdbmsourceclass *lucenegdbmsource = new lucenegdbmsourceclass (); 149 lucenegdbmsource->set_gdbmptr (gdbmhandler); 150 lucenegdbmsource->set_textsearchptr (lucenesearch); 151 cserver->add_source (lucenegdbmsource); 152 } 153 154 155 // inform collection server and everything it contains about its 156 // collection name 157 cserver->configure ("collection", *thiscol); 158 // AZIZ: added on 10/10/00 159 // the cserver object does not have a reference to gsdlhome 160 cserver->configure ("gsdlhome", gsdlhome); 161 162 // GRB: removed proto.add_collectserver (cserver); 163 // GRB: added to build our own cservers list 164 cservers.addcollectserver (cserver); 69 this->add_collection (*thiscol, gsdlhome); 165 70 166 71 ++thiscol; 167 72 } 73 74 this->add_all_collection_groups(gsdlhome); 168 75 } 169 76 } … … 198 105 // are available to decode defaultindex, defaultsubcollection, and 199 106 // defaultlanguage 107 108 bool failed_build_cfg = false; 200 109 if (!build_cfg_read (*((*here).second.c), configinfo.gsdlhome, 201 110 configinfo.collection)) { 111 failed_build_cfg = true; 112 202 113 outconvertclass text_t2ascii; 203 114 logout << text_t2ascii … … 205 116 << configinfo.collection << "\", gsdlhome=\"" 206 117 << configinfo.gsdlhome << "\"\n"; 207 ++here; 208 continue; 209 } 210 118 } 119 120 bool failed_collect_cfg = false; 211 121 if (!collect_cfg_read (*((*here).second.c), configinfo.gsdlhome, 212 122 configinfo.collection)) { 123 failed_collect_cfg = true; 213 124 outconvertclass text_t2ascii; 214 125 logout << text_t2ascii … … 216 127 << configinfo.collection << "\", gsdlhome=\"" 217 128 << configinfo.gsdlhome << "\"\n"; 129 } 130 131 132 bool is_colgroup = (*here).second.c->is_collection_group(); 133 134 if (failed_collect_cfg) { 218 135 ++here; 219 136 continue; 220 137 } 138 139 if (failed_build_cfg && (!is_colgroup)) { 140 ++here; 141 continue; 142 } 143 // let a failed build.cfg through if its 'collect.cfg' marks it as 'collectgroup true' 221 144 222 145 if (!(*here).second.c->init (logout)) return false; … … 258 181 ++thiscol; 259 182 } 183 184 this->add_all_collection_groups(gsdlhome); 260 185 } 261 186 } … … 266 191 const text_t &gsdlhome) { 267 192 268 // if an old collection server exists for this collection we should 269 // delete it first 270 collectservermapclass::iterator here = cservers.begin(); 271 collectservermapclass::iterator end = cservers.end(); 272 while (here != end) { 273 if ((*here).second.c != NULL && (*here).first == collection) { 274 delete (*here).second.c; 275 cservers.erase (here); 276 break; 277 } 278 ++here; 279 } 280 193 this->remove_collection(collection); 194 281 195 // read config file to see if built with mg, mgpp, or lucene 282 196 // -- we can rely on the collection (and therefore the build.cfg) … … 371 285 cserver->configure ("gsdlhome", gsdlhome); 372 286 373 /* Removed from add_collection 24/11/2000; already done elsewhere in collectset.374 // configure receptionist's collectinfo structure375 text_tarray colinfo;376 colinfo.push_back (collection);377 colinfo.push_back (gsdlhome);378 colinfo.push_back (gdbmhome);379 */380 287 cservers.addcollectserver (cserver); 381 288 } … … 399 306 } 400 307 cservers.clear(); 308 } 309 310 void collectset::add_collection_group(const text_t& collection, 311 const text_t& gsdlhome) 312 { 313 text_tarray group; 314 text_t collect_group_dir = filename_cat (gsdlhome, "collect", collection); 315 316 // need to read collect.cfg for 'collectgroup' as class hasn't been initialised through 'init' yet 317 text_t is_collect_group; 318 text_tarray cfgline; 319 text_t key; 320 text_t build_cfg = filename_cat(gsdlhome, "collect", collection, "etc", "collect.cfg"); 321 char *collect_cfgc = build_cfg.getcstr(); 322 ifstream confin(collect_cfgc); 323 324 if (confin) { 325 while (read_cfg_line(confin, cfgline) >= 0) { 326 if (cfgline.size() == 2) { 327 key = cfgline[0]; 328 cfgline.erase(cfgline.begin()); 329 if (key == "collectgroup") { 330 is_collect_group = cfgline[0]; 331 break; 332 } 333 } 334 } 335 confin.close(); 336 } 337 delete []collect_cfgc; 338 339 if (is_collect_group == "true") { 340 341 if (read_dir (collect_group_dir, group)) { 342 343 text_tarray::const_iterator thiscol = group.begin(); 344 text_tarray::const_iterator endcol = group.end(); 345 346 while (thiscol != endcol) { 347 // ignore the modelcol 348 if (*thiscol == "etc") { 349 ++thiscol; 350 continue; 351 } 352 353 this->add_collection (collection + "/" + *thiscol, gsdlhome); 354 355 ++thiscol; 356 } 357 } 358 } 359 } 360 361 void collectset::add_all_collection_groups (const text_t& gsdlhome) 362 363 { 364 collectservermapclass::iterator here = cservers.begin(); 365 collectservermapclass::iterator end = cservers.end(); 366 367 while (here != end) { 368 text_t collection = (*here).second.c->get_collection_name(); 369 this->add_collection_group(collection,gsdlhome); 370 371 ++here; 372 } 373 } 374 375 376 // remove_collection deletes the collection server of collection. 377 // This only needs to be called if a collectionserver is to be 378 // removed while the library is running. The destructor function 379 // cleans up all collectservers when the program exits. 380 void collectset::remove_collection (const text_t &collection) { 381 382 // do nothing if no collection server exists for this collection 383 if (cservers.getcollectserver(collection) == NULL) return; 384 385 // first unload any cached mg databases - we may need to do something 386 // similar to this for mgpp and lucene too 387 if (mgsearch != NULL) { 388 mgsearch->unload_database(); 389 } 390 391 // now delete the collection server object 392 collectservermapclass::iterator here = cservers.begin(); 393 collectservermapclass::iterator end = cservers.end(); 394 395 while (here != end) { 396 if ((*here).second.c != NULL && (*here).first == collection) { 397 delete (*here).second.c; 398 cservers.erase (here); 399 return; 400 } 401 ++here; 402 } 401 403 } 402 404 … … 408 410 void collectset::remove_collection (const text_t &collection, ostream &logout) { 409 411 410 // do nothing if no collection server exists for this collection 411 if (cservers.getcollectserver(collection) == NULL) return; 412 413 // first unload any cached mg databases - we may need to do something 414 // similar to this for mgpp and lucene too 415 if (mgsearch != NULL) { 416 mgsearch->unload_database(); 417 } 418 419 // now delete the collection server object 420 collectservermapclass::iterator here = cservers.begin(); 421 collectservermapclass::iterator end = cservers.end(); 422 423 while (here != end) { 424 if ((*here).second.c != NULL && (*here).first == collection) { 425 delete (*here).second.c; 426 cservers.erase (here); 427 return; 428 } 429 ++here; 430 } 412 remove_collection(collection); 413 431 414 outconvertclass text_t2ascii; 432 415 logout << text_t2ascii << "nullproto::remove_collection: failed to remove collectserver for " -
gsdl/trunk/src/colservr/collectset.h
r9028 r15002 42 42 void add_all_collections (const text_t &gsdlhome); 43 43 void remove_all_collections (); 44 45 void remove_collection (const text_t &collection); 46 void remove_collection (const text_t &collection, ostream& logout); 44 47 45 void remove_collection (const text_t &collection, ostream &logout);46 48 void add_collection (const text_t &collection, 47 49 const text_t &gsdlhome); 50 51 void add_collection_group(const text_t& collection, 52 const text_t& gsdlhome); 53 void add_all_collection_groups (const text_t& gsdlhome); 48 54 49 55 // return the total number of servers in the set -
gsdl/trunk/src/recpt/comtypes.cpp
r13982 r15002 55 55 isBeta=false; 56 56 isSegmented=false; 57 isCollectGroup=false; 57 58 languages.erase(languages.begin(), languages.end()); 58 59 ccsCols.erase(ccsCols.begin(), ccsCols.end()); -
gsdl/trunk/src/recpt/comtypes.h
r13982 r15002 88 88 bool isBeta; 89 89 bool isSegmented; 90 bool isCollectGroup; // used to group a set of collections as one item on the home page 90 91 unsigned long buildDate; 91 92 text_tarray ccsCols; // empty if collection does not use cross-collection searching -
gsdl/trunk/src/recpt/pageaction.cpp
r13982 r15002 180 180 bool first = true; 181 181 while (collist_here != collist_end) { 182 182 183 ColInfoResponse_t *cinfo = recpt->get_collectinfo_ptr ((*rprotolist_here).p, *collist_here, logout); 183 184 … … 253 254 int count = 0; 254 255 while (collist_here != collist_end) { 256 255 257 ColInfoResponse_t *cinfo = recpt->get_collectinfo_ptr ((*rprotolist_here).p, *collist_here, logout); 258 259 text_t arg_g = args["g"]; 260 text_t colname_dir = *collist_here; 256 261 262 if (arg_g.empty()) { 263 // normal top-level home page 264 text_t::const_iterator begin = colname_dir.begin(); 265 text_t::const_iterator end = colname_dir.end(); 266 267 if (findchar(begin,end,'/')!=end) { 268 // no g argument, so generating top level home page 269 // => if colname_dir has "/" in collection name, filter it out 270 271 ++collist_here; 272 continue; 273 } 274 } 275 else { 276 // show only collections in the named group 277 278 279 if (colname_dir == arg_g) { 280 // display about this collect text 281 282 text_t collectionextra = cinfo->get_collectionmeta("collectionextra", args["l"]); 283 if (!collectionextra.empty()) { 284 // prepend text on at start 285 homeextra = "<p>" + collectionextra + "</p>" + homeextra; 286 } 287 288 ++collist_here; 289 continue; 290 } 291 292 293 // => filter out anything that does not start with the group prefix 294 295 if (!starts_with(colname_dir,arg_g + "/")) { 296 ++collist_here; 297 continue; 298 } 299 } 300 301 257 302 if (cinfo != NULL) { 258 if (cinfo->isPublic && ( cinfo->buildDate > 0)) {303 if (cinfo->isPublic && ((cinfo->buildDate > 0)) || (cinfo->isCollectGroup)) { 259 304 260 305 found_valid_col = true; … … 264 309 alt = collectionname; 265 310 } 311 312 313 comerror_t err; 314 text_t optsite = g_EmptyText; 315 text_t site_name = (*rprotolist_here).p->get_site_name (err); 316 if (!site_name.empty()) { optsite = "site="+site_name+"&"; } 317 318 text_t link; 319 320 if (cinfo->isCollectGroup) { 321 link = "<a class=\"collectiontitle\" href=\"_gwcgi_?"+optsite+"a=p&p=home&g=" + *collist_here; 322 link += "&l=" + args["l"] + "&w=" + args["w"] + "\">"; 323 } 324 else { 325 link = "<a class=\"collectiontitle\"href=\"_gwcgi_?"+optsite+"a=p&p=about&c=" + *collist_here; 326 link += "&l=" + args["l"] + "&w=" + args["w"] + "\">"; 327 } 328 329 if (!cinfo->receptionist.empty()) 330 link = "<a class=\"collectiontitle\"href=\"" + cinfo->receptionist + "\">"; 331 266 332 267 333 // url to image: try iconcollectionsmall, then iconcollection … … 291 357 292 358 collectionname 293 = "<img width=\"150\" src=\"" + iconurl + "\" alt=\"" + alt + "\">"; 294 } else { 295 collectionname = alt; 359 = link + "<img width=\"150\" src=\"" + iconurl + "\" alt=\"" + alt + "\">" + "</a>"; 360 } else { 361 362 collectionname = "<div class=\"collecttitle\" style=\"width: 150px; border: 1px solid; \"><p class=\"collectiontitle\" style=\"font-size: 18px; width: 150px; white-space:normal; \">"; 363 collectionname += alt + "</p></div>"; 364 365 collectionname = link + collectionname + "</a>"; 366 296 367 } 297 368 298 369 if (count%configinfo.HomePageCols == 0) 299 homeextra += "<tr valign=\"top\">\n"; 300 301 comerror_t err; 302 text_t optsite = g_EmptyText; 303 text_t site_name = (*rprotolist_here).p->get_site_name (err); 304 if (!site_name.empty()) { optsite = "site="+site_name+"&"; } 305 306 text_t link = "<a href=\"_gwcgi_?"+optsite+"a=p&p=about&c=" + *collist_here; 307 link += "&l=" + args["l"] + "&w=" + args["w"] + "\">"; 308 309 if (!cinfo->receptionist.empty()) 310 link = "<a href=\"" + cinfo->receptionist + "\">"; 311 312 homeextra += "<td>" + link + collectionname + "</a></td>\n"; 370 homeextra += "<tr valign=\"top\">\n"; 371 372 homeextra += "<td align=\"center\">" + collectionname + "</td>\n"; 313 373 314 374 ++count;
Note:
See TracChangeset
for help on using the changeset viewer.