Changeset 15387 for gsdl/trunk/src/oaiservr/listsetsaction.cpp
- Timestamp:
- 2008-05-09T16:29:17+12:00 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gsdl/trunk/src/oaiservr/listsetsaction.cpp
r15198 r15387 18 18 while (param_iterator != params.end()) 19 19 { 20 if (param_iterator->first != "verb" )20 if (param_iterator->first != "verb" && param_iterator->first != "resumptionToken") 21 21 { 22 22 params.erase(param_iterator->first); … … 26 26 } 27 27 28 if (params_size != 1){28 if (params_size != params.getSize()) { 29 29 this->errorType = "badArgument"; 30 30 return false; 31 } 32 33 if (params["resumptionToken"] != "") { 34 ResumptionToken token(params["resumptionToken"]); 35 // TO DO: Resumption token validation checking (the token.isValid() function is useless for ListSets) 36 // if (!token.isValid()) { 37 // this->errorType = "badResumptionToken"; 38 // return false; 39 // } 31 40 } 32 41 … … 57 66 text_tset metadata; 58 67 ofstream logout("oai.log", ios::app); 59 text_tarray *result = new text_tarray;60 68 61 69 // get a list of the collections available … … 65 73 } 66 74 75 // check resumption token 76 int startSet = 0; 77 if (params["resumptionToken"] != "") { 78 ResumptionToken token(params["resumptionToken"]); 79 startSet = token.getPosition() - 1; // first document is said to be 1.. 80 } 81 this->replyToken = NULL; 82 83 this->setNumber = 0; 84 this->setsOutput = 0; 67 85 for(int current_col = 0; current_col < collections.size(); ++current_col) { 68 86 // output the collection as a set, first, then its children 69 87 text_t gsdlCollect = collections[current_col]; 70 88 71 output << " <set>" << endl; 72 output << " <setSpec>" << gsdlCollect << "</setSpec>" << endl;; 73 output << " <setName>" << gsdlCollect << "</setName>" << endl; 74 output << " </set>" << endl; 89 if (this->setsOutput == this->configuration->resumeAfter()) 90 { 91 this->replyToken = new ResumptionToken("", "", ""); 92 this->replyToken->setPosition("", this->setNumber+1); 93 break; 94 } 95 96 if (this->setNumber >= startSet) 97 { 98 output << " <set>" << endl; 99 output << " <setSpec>" << gsdlCollect << "</setSpec>" << endl;; 100 output << " <setName>" << gsdlCollect << "</setName>" << endl; 101 output << " </set>" << endl; 102 this->setsOutput++; 103 } 104 setNumber++; 75 105 76 106 // get all the children of the (relevant) classifier data structures … … 78 108 // and send them to the "recurse_content" list 79 109 for (int c = 0; c < response.numDocs; ++c) { 80 this->recurse_content(output, protocol, gsdlCollect, response.docInfo[c].OID, gsdlCollect); 81 } 110 this->recurse_content(output, protocol, gsdlCollect, response.docInfo[c].OID, gsdlCollect, startSet); 111 } 112 } 113 114 // do a resumption token if required; errors cancel a token... 115 if (this->replyToken != NULL && this->errorType == "") { 116 output << " <resumptionToken>" << endl; 117 output << " " << this->replyToken->getToken() << endl; 118 output << " </resumptionToken>" << endl; 82 119 } 83 120 … … 86 123 87 124 void listsetsaction::recurse_content(ostream &output, recptproto *protocol, text_t &collection, 88 const text_t &classifier, text_t setHierarchy )125 const text_t &classifier, text_t setHierarchy, int startSet) 89 126 { 90 127 // metadata for this call … … 92 129 text_tset metadata; 93 130 ofstream logout("oai.log", ios::app); 131 132 if (this->setsOutput == this->configuration->resumeAfter()) 133 { 134 this->replyToken = new ResumptionToken("", "", ""); 135 this->replyToken->setPosition("", this->setNumber+1); 136 return; 137 } 94 138 95 139 metadata.insert("contains"); … … 135 179 // output the xml for this set; use the classifier id for the name 136 180 // if the title is blank 137 output << " <set>" << endl;138 text_t oai_classifier = classifier;139 oaiclassifier::toOAI(collection, oai_classifier);140 output << " <setSpec>" << oai_classifier << "</setSpec>" << endl;141 output << " <setName>";142 181 // curSet holds the colon-separated sequence of parent sets of the current set 143 182 text_t curSet; 144 if (!title.empty()) { 145 curSet = setHierarchy + ":" + title; 146 } 147 else { 148 curSet = classifier; // Pretty much never gets here (shouldn't, at least) 149 } 150 output << curSet; 151 output << "</setName>" << endl; 152 output << " </set>" << endl; 183 if (this->setNumber >= startSet) 184 { 185 output << " <set>" << endl; 186 text_t oai_classifier = classifier; 187 oaiclassifier::toOAI(collection, oai_classifier); 188 output << " <setSpec>" << oai_classifier << "</setSpec>" << endl; 189 output << " <setName>"; 190 if (!title.empty()) { 191 curSet = setHierarchy + ":" + title; 192 } 193 else { 194 curSet = classifier; // Pretty much never gets here (shouldn't, at least) 195 } 196 output << curSet; 197 output << "</setName>" << endl; 198 output << " </set>" << endl; 199 this->setsOutput++; 200 } 201 this->setNumber++; 153 202 154 203 // get the children of this classifier and iterate them … … 173 222 // parent sets. curSet is pass-by-value, so that as we step out of recursion we remember 174 223 // old set hierarchies. 175 this->recurse_content(output, protocol, collection, child, curSet );224 this->recurse_content(output, protocol, collection, child, curSet, startSet); 176 225 } 177 226
Note:
See TracChangeset
for help on using the changeset viewer.