Ignore:
Timestamp:
2011-08-16T17:52:13+12:00 (13 years ago)
Author:
ak19
Message:

Fixed a new failure of the OAI validation test of GS2's OAI server: where list records is given an Until date that is earlier than the earliestDatestamp. Needs to return a noRecordsMatch. It does now. The calculation of the earliestDatestamp is now shifted to the oaiaction.cpp superclass and called by both identifyaction and listrecordsaction for the identify and listrecords OAI queries, since these tasks need to work with earliestDatestamp.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/runtime-src/src/oaiservr/identifyaction.cpp

    r24114 r24412  
    113113    // their build.cfg file at this point by collectserver::configure. The field
    114114    // is declared in comtypes.h)   
    115     text_t earliestDatestamp = ""; // do not set default to unix epoch time "1970-01-01" yet
    116115   
    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     }
     116    this->calcEarliestDatestamp(protocol, params);  // force the calculation. Sets mEarliestDatestamp member variable
    166117   
    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";
     118    output << utf8convert << "  <earliestDatestamp>"<< this->mEarliestDatestamp <<"</earliestDatestamp>\n";
    173119    output << utf8convert << "  <deletedRecord>no</deletedRecord>\n";
    174120    output << utf8convert << "  <granularity>YYYY-MM-DD</granularity>\n";
Note: See TracChangeset for help on using the changeset viewer.