- Timestamp:
- 2000-07-13T10:21:53+12:00 (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/New_Config_Format-branch/gsdl/src/recpt/receptionist.cpp
r950 r1279 28 28 /* 29 29 $Log$ 30 Revision 1.47.4.1 2000/07/12 22:21:44 sjboddie 31 merged changes to trunk into New_Config_Format branch 32 33 Revision 1.53 2000/07/05 21:49:34 sjboddie 34 Receptionist now caches collection information to avoid making multiple 35 get_collectinfo calls to collection server 36 37 Revision 1.52 2000/07/04 02:15:22 sjboddie 38 fixed bug causing segmentation fault when an invalid collection 39 was supplied as the "c" cgi argument 40 41 Revision 1.51 2000/05/28 09:15:34 sjboddie 42 a few small changes to get an initial release of the local library 43 44 Revision 1.50 2000/05/12 03:09:25 sjboddie 45 minor modifications to get web library compiling under VC++ 6.0 46 47 Revision 1.49 2000/05/04 05:18:46 sjboddie 48 attempting to get end-user collection building to work under windows 49 50 Revision 1.48 2000/04/14 02:52:06 sjboddie 51 tidied up error messaging and set up some debugging info to be output 52 when running library from command line 53 30 54 Revision 1.47 2000/02/17 22:26:17 sjboddie 31 55 set macros for displaying macrons in utf8 … … 227 251 #include "cgiutils.h" 228 252 #include "htmlutils.h" 253 #include "gsdltools.h" 229 254 #include "OIDtools.h" 230 255 #include <assert.h> 231 256 #include <time.h> 232 257 #include <stdio.h> 258 #if defined (GSDL_USE_IOS_H) 233 259 #include <fstream.h> 260 #else 261 #include <fstream> 262 #endif 234 263 235 264 #if defined (__WIN32_) … … 244 273 collectdir.clear(); 245 274 httpprefix.clear(); 246 httpimg .clear();275 httpimg = "/images"; 247 276 gwcgi.clear(); 248 277 macrofiles.erase(macrofiles.begin(), macrofiles.end()); … … 264 293 } 265 294 266 295 void collectioninfo_t::clear () { 296 gsdl_gsdlhome.clear(); 297 gsdl_gdbmhome.clear(); 298 299 info_loaded = false; 300 info.clear(); 301 } 267 302 268 303 receptionist::receptionist () { … … 781 816 utf8outconvertclass text_t2utf8; 782 817 char *lfile = filename.getcstr(); 818 783 819 ofstream log (lfile, ios::app); 784 820 … … 904 940 bool receptionist::produce_content (cgiargsclass &args, ostream &contentout, 905 941 ostream &logout) { 906 942 907 943 // decide on the output conversion class 908 944 text_t &arg_w = args["w"]; … … 1005 1041 text_t colmacrodir = filename_cat (configinfo.collectdir, "macros"); 1006 1042 1007 text_t arraymaindirs;1043 text_tset maindirs; 1008 1044 text_t gsdlmacrodir = filename_cat (configinfo.gsdlhome, "macros"); 1009 maindirs. push_back(gsdlmacrodir);1045 maindirs.insert (gsdlmacrodir); 1010 1046 colinfo_tmap::iterator colhere = configinfo.collectinfo.begin(); 1011 1047 colinfo_tmap::iterator colend = configinfo.collectinfo.end(); 1012 1048 while (colhere != colend) { 1013 gsdlmacrodir = filename_cat ((*colhere).second.gsdl_gsdlhome, "macros"); 1014 maindirs.push_back (gsdlmacrodir); 1049 if (!((*colhere).second.gsdl_gsdlhome).empty()) { 1050 gsdlmacrodir = filename_cat ((*colhere).second.gsdl_gsdlhome, "macros"); 1051 maindirs.insert (gsdlmacrodir); 1052 } 1015 1053 colhere ++; 1016 1054 } … … 1037 1075 // we'll load all copies 1038 1076 if (!foundfile) { 1039 text_t array::const_iterator dirhere = maindirs.begin();1040 text_t array::const_iterator dirend = maindirs.end();1077 text_tset::const_iterator dirhere = maindirs.begin(); 1078 text_tset::const_iterator dirend = maindirs.end(); 1041 1079 while (dirhere != dirend) { 1042 1080 filename = filename_cat (*dirhere, *arrhere); … … 1095 1133 1096 1134 text_t &arg_c = args["c"]; 1097 ColInfoResponse_t cinfo;1098 comerror_t err;1099 1135 recptproto *collectproto = protocols.getrecptproto (arg_c, logout); 1100 collectproto->get_collectinfo (arg_c, cinfo, err, logout); 1101 1102 if (!cinfo.ccsCols.empty()) { 1103 args["ccs"] = 1; 1104 if (args["cc"].empty()) { 1105 text_tarray::const_iterator col_here = cinfo.ccsCols.begin(); 1106 text_tarray::const_iterator col_end = cinfo.ccsCols.end(); 1107 bool first = true; 1108 while (col_here != col_end) { 1109 // make sure it's a valid collection 1110 if (protocols.getrecptproto (*col_here, logout) != NULL) { 1111 if (!first) args["cc"].push_back (','); 1112 args["cc"] += *col_here; 1113 first = false; 1136 if (collectproto == NULL) { 1137 // oops, this collection isn't valid 1138 outconvertclass text_t2ascii; 1139 logout << text_t2ascii << "ERROR: Invalid collection: " << arg_c << "\n"; 1140 args["c"].clear(); 1141 1142 } else { 1143 1144 ColInfoResponse_t *cinfo = get_collectinfo_ptr (collectproto, arg_c, logout); 1145 1146 if (cinfo != NULL) { 1147 if (!cinfo->ccsCols.empty()) { 1148 args["ccs"] = 1; 1149 if (args["cc"].empty()) { 1150 text_tarray::const_iterator col_here = cinfo->ccsCols.begin(); 1151 text_tarray::const_iterator col_end = cinfo->ccsCols.end(); 1152 bool first = true; 1153 while (col_here != col_end) { 1154 // make sure it's a valid collection 1155 if (protocols.getrecptproto (*col_here, logout) != NULL) { 1156 if (!first) args["cc"].push_back (','); 1157 args["cc"] += *col_here; 1158 first = false; 1159 } 1160 col_here ++; 1161 } 1114 1162 } 1115 col_here ++;1116 1163 } 1164 } else { 1165 logout << "ERROR (receptionist::check_mainargs): get_collectinfo_ptr returned NULL\n"; 1117 1166 } 1118 1167 } … … 1226 1275 text_t &collection = args["c"]; 1227 1276 1228 disp.setmacro ("gsdlhome", "Global", configinfo.gsdlhome);1277 disp.setmacro ("gsdlhome", "Global", dm_safe(configinfo.gsdlhome)); 1229 1278 disp.setmacro ("gwcgi", "Global", configinfo.gwcgi); 1230 1279 disp.setmacro ("httpimg", "Global", configinfo.httpimg); … … 1299 1348 } 1300 1349 } 1350 1351 // gets collection info from cache if found or 1352 // calls collection server (and updates cache) 1353 // returns NULL if there's an error 1354 ColInfoResponse_t *receptionist::get_collectinfo_ptr (recptproto *collectproto, 1355 const text_t &collection, 1356 ostream &logout) { 1357 1358 // check the cache 1359 colinfo_tmap::iterator it = configinfo.collectinfo.find (collection); 1360 if ((it != configinfo.collectinfo.end()) && ((*it).second.info_loaded)) { 1361 // found it 1362 return &((*it).second.info); 1363 } 1364 1365 // not cached, get info from collection server 1366 if (collectproto == NULL) { 1367 logout << "ERROR: receptionist::get_collectinfo_ptr passed null collectproto\n"; 1368 return NULL; 1369 } 1370 1371 comerror_t err; 1372 if (it == configinfo.collectinfo.end()) { 1373 collectioninfo_t cinfo; 1374 collectproto->get_collectinfo (collection, cinfo.info, err, logout); 1375 if (err != noError) { 1376 outconvertclass text_t2ascii; 1377 logout << text_t2ascii << "ERROR (receptionist::getcollectinfo_ptr): \"" 1378 << get_comerror_string (err) << "\"while getting collectinfo\n"; 1379 return NULL; 1380 } 1381 cinfo.info_loaded = true; 1382 configinfo.collectinfo[collection] = cinfo; 1383 return &(configinfo.collectinfo[collection].info); 1384 } else { 1385 collectproto->get_collectinfo (collection, (*it).second.info, err, logout); 1386 if (err != noError) { 1387 outconvertclass text_t2ascii; 1388 logout << text_t2ascii << "ERROR (receptionist::getcollectinfo_ptr): \"" 1389 << get_comerror_string (err) << "\"while getting collectinfo\n"; 1390 return NULL; 1391 } 1392 (*it).second.info_loaded = true; 1393 return &((*it).second.info); 1394 } 1395 }
Note:
See TracChangeset
for help on using the changeset viewer.