Changeset 11732
- Timestamp:
- 2006-04-28T11:26:25+12:00 (18 years ago)
- Location:
- trunk/gsdl/src/oaiservr
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/src/oaiservr/abstractlistaction.cpp
r11311 r11732 3 3 4 4 #include "oaitools.h" 5 6 // The following makes sure that we don't actually use ResumptionTokens7 #define MAXRECORDS -18 5 9 6 bool abstractlistaction::validateAction(recptproto *protocol, oaiargs ¶ms, int &numArgs) … … 108 105 } 109 106 107 this->replyToken = NULL; 108 110 109 // if we've been asked for a set, then use it! 111 110 if (params["set"] != "") { … … 128 127 else { 129 128 if (this->check_classifier(protocol, gsdlCollect, gsdlSet)) { 130 this->recurse_set(output, protocol, gsdlCollect, gsdlSet, params );129 this->recurse_set(output, protocol, gsdlCollect, gsdlSet, params, token); 131 130 } 132 131 } … … 146 145 147 146 // do a resumption token if required; errors cancel a token... 148 if (this->replyToken != NULL && this->errorType != "") {149 output << " <resumptionToken>";150 output << this->replyToken->getToken();151 output << " </resumptionToken>";147 if (this->replyToken != NULL && this->errorType == "") { 148 output << " <resumptionToken>" << endl; 149 output << " " << this->replyToken->getToken() << endl; 150 output << " </resumptionToken>" << endl; 152 151 } 153 152 … … 196 195 continue; 197 196 } 198 197 198 199 199 // Check that the item with the 0ID 'gsdl_id' has a lastmodified field that fits within 200 200 // the required date range (if specified). … … 212 212 } 213 213 214 // if we've output MAXRECORDSdocuments; prepare a resumptionToken215 if (this->outputDocs == MAXRECORDS) {214 // if we've output the number of resumption documents; prepare a resumptionToken 215 if (this->outputDocs == this->configuration->resumeAfter()) { 216 216 this->replyToken = new ResumptionToken(gsdlCollect, "", ""); 217 217 this->replyToken->setPosition("", i+2); … … 232 232 text_tarray collections; 233 233 text_t gsdlCollect = ""; 234 ResumptionToken *token = NULL; 234 235 235 236 // get a list of the collections available 236 protocol->get_collection_list(collections, err, output); 237 237 collections = this->configuration->getCollectionsList(); 238 // protocol->get_collection_list(collections, err, output); 239 240 if (params["resumptionToken"] != "") { 241 token = new ResumptionToken(params["resumptionToken"]); 242 } 243 238 244 for(int current_col = 0; current_col < collections.size(); ++current_col){ 239 245 gsdlCollect = collections[current_col]; 246 247 // ignore all leading collections before the one that matches the resumptiontoken 248 if (token != NULL && 249 token->getCollection() != gsdlCollect) 250 { continue; 251 } 252 240 253 this->output_content_for_col(output, protocol, gsdlCollect, cinfo, err, params); 254 255 // once we've output at least one collection, continue 256 // outputting all others until the resumption total hits 257 token = NULL; 258 259 if (this->outputDocs == this->configuration->resumeAfter()) { 260 break; 261 } 241 262 } 242 263 } … … 295 316 296 317 void abstractlistaction::recurse_set(ostream &output, recptproto *protocol, const text_t &collection, 297 const text_t &classifier, oaiargs ¶ms )318 const text_t &classifier, oaiargs ¶ms, ResumptionToken *resumptionToken) 298 319 { 299 320 // metadata for this call … … 304 325 text_t until = params["until"]; 305 326 text_t metadataPrefix = params["metadataPrefix"]; 306 ResumptionToken resumptionToken(params["resumptionToken"]);327 // ResumptionToken resumptionToken(params["resumptionToken"]); 307 328 int startPos = 0; 308 329 … … 322 343 if (params["resumptionToken"] != "") { 323 344 // if we're at a resumptionToken 324 if (classifier == resumptionToken .getNode()) {325 startPos = resumptionToken .getPosition();345 if (classifier == resumptionToken->getNode()) { 346 startPos = resumptionToken->getPosition(); 326 347 } 327 348 else { 328 text_t fullNode = resumptionToken .getNode();349 text_t fullNode = resumptionToken->getNode(); 329 350 text_t::iterator leafIter = fullNode.begin() + classifier.size(); 330 351 … … 377 398 // children which are classifiers are recursed 378 399 else { 379 this->recurse_set(output, protocol, collection, child, params); 380 } 381 382 if (this->outputDocs == MAXRECORDS) { 383 this->replyToken = new ResumptionToken(collection, params["set"], ""); 384 this->replyToken->setPosition(classifier, c+2); 385 } 386 } 387 } 388 389 390 391 400 if (resumptionToken != NULL) { 401 int depth = countchar(classifier.begin(), classifier.end(), '.'); 402 resumptionToken->setOffset(depth, c+2); 403 } 404 this->recurse_set(output, protocol, collection, child, params, resumptionToken); 405 } 406 407 if (this->outputDocs == this->configuration->resumeAfter()) { 408 // this->replyToken = new ResumptionToken(collection, params["set"], ""); 409 this->replyToken = resumptionToken; 410 this->replyToken->setPosition(classifier, c+2); 411 } 412 } 413 } 414 415 416 417 -
trunk/gsdl/src/oaiservr/abstractlistaction.h
r8182 r11732 17 17 ColInfoResponse_t &cinfo, comerror_t &err, oaiargs ¶ms); 18 18 virtual void recurse_set(ostream &output, recptproto *protocol, const text_t &collection, 19 const text_t &classifier, oaiargs ¶ms );19 const text_t &classifier, oaiargs ¶ms, ResumptionToken *resumptionToken); 20 20 protected: 21 21 bool prevDocSeen; -
trunk/gsdl/src/oaiservr/oaiconfig.cpp
r9608 r11732 34 34 35 35 oaiconfig::oaiconfig() : configurable () { 36 this->resumptionSize = -1; // Default = do not use resumption tokens 36 37 } 37 38 … … 41 42 text_t mainconfig = filename_cat(gsdlhome, "etc", "oai.cfg"); 42 43 this->collection = ""; 44 this->resumptionSize = -1; 43 45 this->read_configfile(mainconfig); 44 46 45 47 // then if we've not got a specified collection in the gsdlcollect 46 48 // parameter, read in all the collection's individual configurations … … 66 68 ++here; 67 69 } 70 } 71 72 int oaiconfig::resumeAfter() 73 { return this->resumptionSize; 68 74 } 69 75 … … 186 192 this->oaiVersion = cfgline[0]; 187 193 } 194 else if (key == "resumeafter" && cfgline.size() >= 1) { 195 this->resumptionSize = cfgline[0].getint(); 196 } 188 197 // get and note a maintainer item to support the Identify Verb of OAI 189 198 else if (key == "maintainer" && cfgline.size() >= 1) { -
trunk/gsdl/src/oaiservr/oaiconfig.h
r8303 r11732 32 32 text_tmap * getInformation() { return &this->infoMap; } 33 33 int getOAIVersion(); 34 int resumeAfter(); 34 35 private: 35 36 void configureCollection(const text_t &gsdlhome, const text_t &collection); … … 41 42 text_t collection; // Used to track which collection is being configured 42 43 text_t oaiVersion; // The version of OAI running 44 int resumptionSize; // The number of items to produce before spitting out a 45 // resumptionToken 43 46 }; 44 47 #endif -
trunk/gsdl/src/oaiservr/resumptiontoken.cpp
r8223 r11732 25 25 { text_t::const_iterator first = URN.begin(); 26 26 text_t::const_iterator last = URN.end(); 27 text_t::const_iterator second; 27 28 28 29 this->collection = ""; … … 41 42 42 43 // increment past the first colon to get the location 44 first = ++here; 45 46 // get the collection, browseNode 47 here = findchar(first, last, ','); 48 if (here == last) { 49 return; 50 } 51 52 second = findchar(first, here,'.'); 53 this->collection = substr(first, second); 54 55 // cerr << "Collection " << this->collection << endl; 56 57 if (second != here) { 58 this->browseNode = substr(second, here); 59 } 60 else { 61 first = here; 62 } 63 // get past the ',' 43 64 first = ++here; 44 65 45 // get the collection 46 here = findchar(first, last, '.'); 66 // find the second ',' to delimit the position stack 67 second = findchar(first, last, ','); 68 69 // if not found, then get build and start item 70 if (second != first) { 71 // extract list and step past it 72 text_t offsetList = substr(first, second); 73 first = ++second; 74 75 do { 76 second = findchar(offsetList.begin(), offsetList.end(), '.'); 77 if (second == offsetList.end()) 78 break; 79 80 // extract and push the next position 81 text_t thisPos = substr(offsetList.begin(), second); 82 this->browsePosition.push_back(thisPos.getint()); 83 84 // pop the position from the list 85 offsetList = substr(++second, offsetList.end()); 86 } while (TRUE); 87 this->browsePosition.push_back(offsetList.getint()); 88 } 89 else { 90 first ++; 91 } 92 93 // now find the build date marker 94 here = findchar(first, last, '-'); 47 95 if (here == first) { 48 return;96 this->startItem = substr(first, last).getint(); 49 97 } 50 this->collection = substr(first, here);51 52 first = ++here;53 54 // get the browse node55 here = findchar(first, last, ',');56 57 // now, we *may* have truncated items where we start with the first58 // item in a node (i.e. suppress the ',0' for one reason or another,59 // let's be forgiving if we can...60 if (here == first) {61 this->startItem = 0;62 63 here = findchar(first, last, '-');64 65 // no build date - keep trying...66 if (here == first) {67 this->browseNode = substr(first, last);68 }69 else {70 this->browseNode = substr(first, here);71 this->buildDate = substr(++here, last);72 }73 }74 // got a proper item indicator...75 98 else { 76 // record the browse node 77 this->browseNode = substr(first, here); 78 79 // get past the ',' 80 first = ++here; 81 82 // now find the build date marker 83 here = findchar(first, last, '-'); 84 if (here == first) { 85 this->startItem = substr(first, last).getint(); 86 } 87 else { 88 this->startItem = substr(first, here).getint(); 89 this->buildDate = substr(++here, last); 90 } 99 this->startItem = substr(first, here).getint(); 100 this->buildDate = substr(++here, last); 91 101 } 92 102 } … … 111 121 if (this->browseNode != "") { 112 122 reply = reply + "." + this->browseNode; 123 } 124 reply = reply + ","; 125 for (int i = 0; i < this->browsePosition.size(); i++) { 126 if (i != 0) { 127 reply.append("."); 128 } 129 reply.appendint(i); 113 130 } 114 131 reply = reply + ","; -
trunk/gsdl/src/oaiservr/resumptiontoken.h
r8182 r11732 2 2 #define _RESUMPTIONTOKEN_H_ 3 3 4 #include <vector> 5 4 6 #include "text_t.h" 7 8 using namespace std; 5 9 6 10 class ResumptionToken … … 8 12 text_t collection; 9 13 text_t browseNode; 14 vector<int> browsePosition; 10 15 int startItem; 11 16 text_t buildDate; … … 16 21 ResumptionToken(const text_t &URN); 17 22 text_t getToken(); 23 18 24 void setPosition(const text_t &node, int startItem); 25 19 26 text_t getCollection() { return collection; } 20 27 text_t getNode() { return browseNode; } 21 28 int getPosition() { return startItem; } 29 int getOffsetDepth() { return this->browsePosition.size(); } 30 int setOffset(int depth, int position) { this->browsePosition[depth] = position; } 31 int getOffset(int offset) { return this->browsePosition[offset]; } 22 32 bool isValid(); 23 33 };
Note:
See TracChangeset
for help on using the changeset viewer.