Changeset 24114 for main/trunk/greenstone2/runtime-src/src/oaiservr
- Timestamp:
- 2011-06-03T22:44:28+12:00 (13 years ago)
- Location:
- main/trunk/greenstone2/runtime-src/src/oaiservr
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone2/runtime-src/src/oaiservr/identifyaction.cpp
r22739 r24114 26 26 27 27 #include "identifyaction.h" 28 #include "oaitools.h" 28 29 29 30 bool identifyaction::validateAction(recptproto *protocol, oaiargs ¶ms) … … 103 104 // not to be worth the effort of trolling through all the lastmodified dates (by others with more 104 105 // say than me) 105 output << utf8convert << " <earliestDatestamp>1970-01-01</earliestDatestamp>\n"; 106 107 // The above was before. However, now we mirror GS3 way of dealing with 108 // earliestDatestamp by going through the earliestDatestamp field of each OAI 109 // collection's build.cfg in order to work out earliestdatestamp of this Repository: 110 // by going through all the collections and getting the earliest among the 111 // "earliestDatestamp" values stored for each collection in its build.cfg 112 // (the earliestDatestamp for a collection has already been extracted from 113 // their build.cfg file at this point by collectserver::configure. The field 114 // is declared in comtypes.h) 115 text_t earliestDatestamp = ""; // do not set default to unix epoch time "1970-01-01" yet 116 117 // Get a list of the OAI-enabled collections available 118 text_tarray& collections = this->configuration->getCollectionsList(); 119 if (collections.size() > 0) 120 { 121 // get the identifier from the params 122 text_t identifier = params["identifier"]; 123 text_t oai_OID_prefix = "oai:"+this->configuration->getRepositoryId()+":"; 124 identifier.replace(oai_OID_prefix, ""); 125 126 // Get the current collection from the identifier 127 text_t collection_name = ""; 128 oaiclassifier::toGSDL(collection_name, identifier); 129 130 // Find the starting collection 131 text_tarray::iterator collection_iterator = collections.begin(); 132 while (collection_iterator != collections.end()) 133 { 134 if (collection_name == "" || collection_name == *collection_iterator) 135 { 136 break; 137 } 138 139 collection_iterator++; 140 } 141 142 // Now loop through the remaining collections 143 // to work out the earliest datestamp 144 while (collection_iterator != collections.end()) 145 { 146 collection_name = (*collection_iterator); 147 148 ColInfoResponse_t cinfo; 149 comerror_t err; 150 protocol->get_collectinfo(collection_name, cinfo, err, cerr); 151 if (err == noError) { 152 text_t eDatestamp = cinfo.earliestDatestamp; 153 time_t raw_time = (time_t)eDatestamp.getint(); 154 eDatestamp = this->parseDatestamp(raw_time); 155 156 if(earliestDatestamp == "") { // first earliestdatestamp we've seen for an oai collection 157 earliestDatestamp = eDatestamp; 158 } else if(eDatestamp < earliestDatestamp) { 159 earliestDatestamp = eDatestamp; 160 } 161 } 162 collection_iterator++; 163 164 } 165 } 166 167 // if repository's earliestDatestamp is still unset, default to unix epoch time 168 if(earliestDatestamp == "") { 169 earliestDatestamp = "1970-01-01"; 170 } 171 172 output << utf8convert << " <earliestDatestamp>"<< earliestDatestamp <<"</earliestDatestamp>\n"; 106 173 output << utf8convert << " <deletedRecord>no</deletedRecord>\n"; 107 174 output << utf8convert << " <granularity>YYYY-MM-DD</granularity>\n"; -
main/trunk/greenstone2/runtime-src/src/oaiservr/oaiconfig.cpp
r23233 r24114 83 83 if (!this->configureCollection(gsdlhome, *here)) { 84 84 this->collectList.erase(here); 85 } 86 85 } 87 86 } 88 87 else { … … 119 118 if (!file_exists(cnfgfile)) { 120 119 return false; 121 } 120 } 121 122 122 this->collection = gsdlcollect; 123 123 this->read_configfile(cnfgfile); 124 124 125 // to work out the earliestDatestamp for the repository, need to 126 // to read in the build.cfg file of each OAI collection, in order to 127 // find the oldest earliestDatestamp field of all the OAI collections 128 text_t buildcnfgfile = filename_cat(gsdlhome, "collect", gsdlcollect, "index", "build.cfg"); 129 if (file_exists(buildcnfgfile)) { 130 this->read_configfile(buildcnfgfile); 131 } 132 125 133 return true; 126 134 } … … 309 317 this->oaiVersion = cfgline[0]; 310 318 } 311 312 } 319 } 320 313 321 314 322 text_t oaiconfig::generateBaseServerURL() {
Note:
See TracChangeset
for help on using the changeset viewer.