Changeset 27534 for main/trunk/greenstone2/runtime-src/src
- Timestamp:
- 2013-06-04T15:56:26+12:00 (11 years ago)
- Location:
- main/trunk/greenstone2/runtime-src/src/oaiservr
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone2/runtime-src/src/oaiservr/abstractlistaction.cpp
r27528 r27534 84 84 } 85 85 86 // Case for no "set" argument present - - output all records in all collections87 // or we are a super collection86 // Case for no "set" argument present - output all records in all collections & super colls 87 // Case for super collection set - output all records in all collections in this super coll 88 88 else 89 89 { … … 94 94 collections = this->configuration->getSuperCollectionCollections(set_name); 95 95 } else { 96 collections = this->configuration->getCollectionsList(); 96 97 collections = this->configuration->getAllCollectionsList();//this->configuration->getCollectionsList(); 98 97 99 } 98 100 if (collections.size() == 0) … … 121 123 { 122 124 // If output_content_for_set() returns false a resumption token has been output, so it's time to stop 123 if (output_content_for_set(output, protocol, params, *collection_iterator, "", "") == false)125 if (output_content_for_set(output, protocol, params, *collection_iterator, "", set_name) == false) 124 126 { 125 127 return true; -
main/trunk/greenstone2/runtime-src/src/oaiservr/listidsaction.cpp
r27528 r27534 210 210 211 211 // Check the collection is one that is in the list in the oai.cfg file 212 text_tarray &collections = this->configuration->getCollectionsList(); 213 bool collection_found = false; 214 for (int c = 0; c < collections.size(); c++) 215 { 216 if (collections[c] == collection) 217 { 218 collection_found = true; 219 break; 220 } 221 } 222 223 // The collection was not found 224 if (!collection_found) 225 { 226 this->errorType = "badArgument"; 227 return false; 228 } 212 if (!this->configuration->isValidCollection(collection)) { 213 this->errorType = "badArgument"; 214 return false; 215 } 229 216 230 217 // Check the child set if it was given -
main/trunk/greenstone2/runtime-src/src/oaiservr/listrecsaction.cpp
r24412 r27534 165 165 text_t set = params["set"]; 166 166 167 // Is the set a super collection?? 168 text_tarray &super_collections = this->configuration->getSuperCollectionsList(); 169 bool super_collection_found = false; 170 for (int c = 0; c < super_collections.size(); c++) 171 { 172 if (super_collections[c] == set) 173 { 174 super_collection_found = true; 175 break; 176 } 177 } 178 if (super_collection_found) { 179 this->errorType = ""; 180 return true; 181 } 182 167 183 // Extract the collection name from the set specification 168 184 text_t collection = ""; … … 180 196 181 197 // Check the collection is one that is in the list in the oai.cfg file 182 text_tarray &collections = this->configuration->getCollectionsList(); 183 bool collection_found = false; 184 for (int c = 0; c < collections.size(); c++) 185 { 186 if (collections[c] == collection) 187 { 188 collection_found = true; 189 break; 190 } 191 } 192 193 // The collection was not found 194 if (!collection_found) 195 { 196 this->errorType = "badArgument"; 197 return false; 198 } 198 if (!this->configuration->isValidCollection(collection)) { 199 this->errorType = "badArgument"; 200 return false; 201 } 199 202 200 203 // Check the child set if it was given -
main/trunk/greenstone2/runtime-src/src/oaiservr/listsetsaction.cpp
r27528 r27534 124 124 } 125 125 126 // if no resumption token, output the super colls. Otherwise, start from 127 // the collection list correct position. 128 // Assume for now that super coll list is always first in the list of sets, 129 // and we never issue a resumption token part way through the list of super colls 130 // TODO handle resumption tokens properly. 131 text_t set_name =""; 132 if (position == "") { 133 text_tarray& supercolls = this->configuration->getSuperCollectionsList(); 134 text_tarray::iterator supercoll_iterator = supercolls.begin(); 135 while (supercoll_iterator != supercolls.end()) { 136 set_name = (*supercoll_iterator); 137 output_content_for_supercol(output, set_name); 138 supercoll_iterator++; 139 } 140 } 141 142 126 143 // Get a list of the collections available 127 144 text_tarray& collections = this->configuration->getCollectionsList(); 128 145 if (collections.size() == 0) 129 146 { 130 return false; 131 } 132 133 // if no resumption token, output the super colls. Otherwise, start from 134 // the collection list correct position. 135 // Assume for now that super coll list is always in the first list 136 text_t set_name =""; 137 if (position == "") { 138 text_tarray& supercolls = this->configuration->getSuperCollectionsList(); 139 if (collections.size() != 0) { 140 text_tarray::iterator supercoll_iterator = supercolls.begin(); 141 while (supercoll_iterator != supercolls.end()) { 142 set_name = (*supercoll_iterator); 143 output_content_for_supercol(output, set_name); 144 supercoll_iterator++; 145 } 146 } 147 } 147 if (this->setsOutput ==0) { 148 // we had no super colls either 149 return false; 150 } 151 return true; 152 } 153 148 154 // Get the current collection from the position value 149 155 text_t collection_name = ""; -
main/trunk/greenstone2/runtime-src/src/oaiservr/oaiaction.cpp
r27528 r27534 414 414 if(oaiVersion >= 200){ 415 415 416 // A doc is always a member of its collection set 417 output << " <setSpec>" << collection_id << "</setSpec>" << endl; 416 // A doc is only a member of its collection set if hte collection is valid 417 // Can have super collecitons containging collecitons that are not individually valid 418 if (this->configuration->isValidCollection(collection_id)) { 419 output << " <setSpec>" << collection_id << "</setSpec>" << endl; 420 } 418 421 // are we part of a super collection? 419 422 text_tarray super_colls = this->configuration->getSuperCollectionsForThisCollection(collection_id); -
main/trunk/greenstone2/runtime-src/src/oaiservr/oaiconfig.cpp
r27528 r27534 110 110 } 111 111 return 200; 112 } 113 114 bool oaiconfig::isValidCollection(const text_t &collection) 115 { 116 for (int c = 0; c < this->collectList.size(); c++) 117 if (this->collectList[c] == collection) { 118 return true; 119 } 120 return false; 112 121 } 113 122 … … 208 217 for (int c = 0; c < cfgline.size(); ++c) { 209 218 this->collectList.push_back(cfgline[c]); 219 addToAllCollectionsList(cfgline[c]); 210 220 } 211 221 } 212 222 else if (key == "oaisupercollection" && cfgline.size() > 1) { 213 223 214 // Configure a hierarchical superset224 // Configure a super collection set 215 225 // The line should read 216 226 // … … 240 250 } 241 251 this->collectMap[sub_coll]->superCollectList.push_back(super_set); 252 addToAllCollectionsList(sub_coll); 242 253 } 243 254 } … … 358 369 } 359 370 } 360 371 372 void oaiconfig::addToAllCollectionsList(const text_t coll_name) { 373 374 for (int c=0; c<this->allCollectList.size(); c++) { 375 if (allCollectList[c] == coll_name) return; 376 } 377 this->allCollectList.push_back(coll_name); 378 379 } 361 380 362 381 text_t oaiconfig::generateBaseServerURL() { … … 481 500 } 482 501 483 text_tarray oaiconfig::getSuperCollectionsForThisCollection(const text_t &collection) { 502 503 text_tarray oaiconfig::getSuperCollectionsForThisCollection(const text_t &collection) 504 { 484 505 485 506 text_tarray super_colls; -
main/trunk/greenstone2/runtime-src/src/oaiservr/oaiconfig.h
r27528 r27534 63 63 virtual void configure(const text_t &key, const text_tarray &cfgline); 64 64 text_tarray & getCollectionsList() { return this->collectList; } 65 // get a list of all collections - those part of a super coll and those individual ones 66 text_tarray & getAllCollectionsList() {return this->allCollectList; } 65 67 text_tarray & getSuperCollectionsList() { return this->superCollectList; } 68 // get the list of collections for this super coll 66 69 text_tarray & getSuperCollectionCollections(const text_t super_coll) { 67 70 return this->superCollectMap[super_coll]->collectionList; 68 71 } 72 // is this collection valid 73 bool isValidCollection(const text_t &collection); 74 // what super collections is this collection part of? 69 75 text_tarray getSuperCollectionsForThisCollection(const text_t &collection); 70 76 text_tset & getMetadataSet() { return this->metadataSet; } … … 86 92 private: 87 93 bool configureCollection(const text_t &gsdlhome, const text_t &collection); 94 void addToAllCollectionsList(const text_t coll_name); 88 95 text_t generateBaseServerURL(); 89 96 text_t repositoryName; // human readable name … … 106 113 text_tarray superCollectList; //a list of super collections. may be empty 107 114 oaisupercollectmap superCollectMap; // The configuration of the super collections 115 text_tarray allCollectList; //a list of all collections, includes those in collectList and those that are part of a super collection and not in collectList 108 116 }; 109 117 #endif
Note:
See TracChangeset
for help on using the changeset viewer.