- Timestamp:
- 2017-02-08T18:31:18+13:00 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone2/runtime-src/src/colservr/source.cpp
r21772 r31387 33 33 { 34 34 db_ptr = NULL; 35 oaidb_ptr = NULL; 35 36 textsearchptr = NULL; 36 37 classname = "source"; … … 41 42 if (db_ptr != NULL) delete db_ptr; 42 43 if (textsearchptr != NULL) delete textsearchptr; 44 45 // http://stackoverflow.com/questions/677620/do-i-need-to-explicitly-call-the-base-virtual-destructor 46 // Answer: "No, destructors are called automatically [by the derived destructor] in the reverse 47 // order of construction. (Base classes last). Do not call base class destructors." 48 // The link also explains why the destructors should be declared as virtual in the header files. 49 50 // now delete the oaidb object pointed to by the oaidb_ptr too 51 if (oaidb_ptr != NULL) delete oaidb_ptr; 52 oaidb_ptr = NULL; 43 53 } 44 54 … … 78 88 } 79 89 90 text_t sourceclass::getcollectionpath() 91 { 92 text_t resolved_filename; 93 94 if (gsdlhome==dbhome) { 95 // dbhome has defaulted to gsdlhome which we take to means the 96 // database has been specifically moved out of gsdlhome area. 97 // => it should be whereever collecthome is set to 98 resolved_filename = filename_cat(collecthome, collection); 99 } 100 else { 101 // dbhome is explicitly set to something other than gsdlhome 102 // => use dbhome 103 resolved_filename = filename_cat(dbhome, "collect", collection); 104 } 105 106 return resolved_filename; 107 } 108 80 109 text_t sourceclass::resolve_db_filename(const text_t& idx, 81 110 const text_t& file_ext) … … 91 120 // are also drawn from one object 92 121 122 /* 93 123 text_t resolved_filename; 94 124 … … 105 135 resolved_filename = filename_cat(dbhome, "collect", collection, "index", "text", idx); 106 136 } 107 137 */ 138 139 text_t resolved_filename = filename_cat(getcollectionpath(), "index", "text", idx); 108 140 resolved_filename += file_ext; 109 141 … … 111 143 } 112 144 113 145 text_t sourceclass::resolve_oaidb_filename(const text_t& file_ext) 146 { 147 text_t resolved_filename = filename_cat(getcollectionpath(), "etc", "oai-inf"); 148 149 resolved_filename += file_ext; 150 151 return resolved_filename; 152 } 114 153 115 154 // init should be called after all the configuration is done but … … 172 211 } 173 212 213 oaidb_filename = resolve_oaidb_filename(oaidb_ptr->getfileextension()); 214 174 215 return true; 175 216 } … … 207 248 } 208 249 250 // get_oai_metadata fills out the oai metadata from oaidb if possible 251 // if it is not responsible for the given OID then it will return false. 252 bool sourceclass::get_oai_metadata (const text_t &requestParams, const text_t &refParams, 253 bool getParents, const text_tset &fields, 254 const text_t &OID, text_t &deleted_status, MetadataInfo_tmap &metadata, 255 comerror_t &err, ostream &logout) 256 { 257 outconvertclass text_t2ascii; 258 metadata.erase(metadata.begin(), metadata.end()); 259 err = noError; 260 261 //logout << text_t2ascii << "sourceclass::get_oai_meta for OID: " << OID << "\n"; 262 263 // ONLY if we're doing any OAI stuff (FROAI will be set then) will we even be in here 264 // So next try to open the oai-inf db if it exists for this collection 265 if (!file_exists(oaidb_filename)) { // if the oaidb file doesn't even exist, let's not bother with oaidb 266 267 logout << text_t2ascii 268 << "warning: collection's oai-inf database \"" << oaidb_filename << "\" does not exist\n\n"; 269 return false; 270 271 } else { // let's try opening the oaidb file 272 oaidb_ptr->setlogout(&logout); 273 if (!oaidb_ptr->opendatabase (oaidb_filename, DB_READER, 100, false)) { 274 // most likely a system problem (we have already checked that the database exists just above) 275 logout << text_t2ascii 276 << "system problem: open on database \"" 277 << oaidb_filename << "\" failed\n\n"; 278 err = systemProblem; 279 return false; 280 } // now we've opened the oai-inf db file successfully 281 } 282 283 // get the metadata (deleted status, timestamp, datestamp) for OID, and pushback onto the metadata array 284 infodbclass oai_info; 285 if (!oaidb_ptr->getinfo(OID, oai_info)) { // OID not found in oai_inf db 286 logout << text_t2ascii 287 << "warning: lookup for OID \"" << OID 288 << "\" in etc/oai-inf db failed when getting metadata (in sourceclass source.cpp).\n\n"; 289 290 return false; 291 } else { 292 //logout << text_t2ascii << "@@@@ getting metadata for OID \"" << OID << "\" from etc/oai-inf db.\n\n"; 293 //logout << text_t2ascii << "@@@@ timestamp: " << oai_info["timestamp"] << "\n\n"; 294 295 metadata["oaiinf.status"].isRef = false; 296 metadata["oaiinf.status"].values.push_back(oai_info["status"]); 297 metadata["oaiinf.timestamp"].isRef = false; 298 metadata["oaiinf.timestamp"].values.push_back(oai_info["timestamp"]); 299 metadata["oaiinf.datestamp"].isRef = false; 300 metadata["oaiinf.datestamp"].values.push_back(oai_info["datestamp"]); 301 } 302 303 // we're done with oai-inf db 304 305 oaidb_ptr->closedatabase(); // don't leave files open 306 307 return true; 308 } 309 209 310 210 311 // get_metadata fills out the metadata if possible, if it is not responsible … … 213 314 bool getParents, const text_tset &fields, 214 315 const text_t &OID, MetadataInfo_tmap &metadata, 215 comerror_t &err, ostream &logout )316 comerror_t &err, ostream &logout, bool append) 216 317 { 217 318 outconvertclass text_t2ascii; 218 319 219 metadata.erase(metadata.begin(), metadata.end()); 320 if(!append) { 321 metadata.erase(metadata.begin(), metadata.end()); 322 } 220 323 221 324 err = noError;
Note:
See TracChangeset
for help on using the changeset viewer.