Changeset 31903


Ignore:
Timestamp:
08/18/17 19:28:42 (3 years ago)
Author:
ak19
Message:

I hope these are all the changes necessary on the runtime side of GS2 to get the OAI server validation working for GS2: instead of working out the earliest datetime stamp of the OAI repository by comparing the builddate in index/build.cfg of each OAI collection and selecting the earliest, the oai-inf.db is now storing the special earliesttimestamp record. The timestamp of this record represents its collection's earliest timestamp. And the earliest of these among all OAI collections is now the earliest datetime of the OAI repository.

Location:
main/trunk/greenstone2/runtime-src/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/runtime-src/src/colservr/browsefilter.cpp

    r31394 r31903  
    143143    if(parentnode == "oai") { // doing an OAI listidentifiers request
    144144
    145       // open up the oai-inf db, if it exists, and return all IDs
    146       // if it doesn't exist, proceed as usual
     145      // open up the oai-inf db if it exists, and return all IDs *except* the special OID=OAI_EARLIESTTIMESTAMP_OID
     146      // if oai-inf db doesn't exist, proceed as usual
    147147      success = get_oaiinf_db_entries(response, err, logout); //adds any stuff in oai-inf db for the current OID to resultdoc.metadata
    148148
     
    377377   
    378378    resultdoc.OID = (*key_here);
    379    
     379   
     380    // OAI_EARLIESTTIMESTAMP_OID is the OID of a special record that we'll ignore
     381    // here in browsefilter.cpp, since it's not a doc.
     382    // When the *metadata* for this special OID is requested, source.cpp will handle it
     383    if(resultdoc.OID == OAI_EARLIESTTIMESTAMP_OID) {
     384      ++key_here;
     385      continue;
     386    }
     387
    380388    if(!oaidb_ptr->getinfo(resultdoc.OID, oai_info)) {
    381389      logout << text_t2ascii
  • main/trunk/greenstone2/runtime-src/src/colservr/collectserver.cpp

    r31387 r31903  
    535535      // first check for oai metadata from the oai_db, if asked for it (if FROAI is set)
    536536      if(((*source_here).s != NULL) &&
    537          request.filterResultOptions & FROAI &&
     537         (request.filterResultOptions & FROAI) &&
    538538         ((*source_here).s->get_oai_metadata(request.requestParams, request.refParams,
    539539                         request.getParents, request.fields,
     
    546546      }
    547547
     548      // if OID is the special OAI specific OAI_EARLIESTTIMESTAMP_OID,
     549      // then we'd have got its OAI meta above if we were requested to do so.
     550      // Either way, we won't be additionally getting regular meta for this OID,
     551      // as it's not a real doc OID, so we stop processing this OID here.
     552      if((*resultdoc_here).OID == OAI_EARLIESTTIMESTAMP_OID) {
     553        ++source_here;
     554        if(processed == true) break;
     555        else continue;
     556      }
     557 
    548558      // We may or may not have got oai_meta (depends on if FROAI was set).
    549559      // If we didn't get oai_meta, then deleted_status would still be "".
  • main/trunk/greenstone2/runtime-src/src/colservr/comtypes.h

    r31387 r31903  
    4848#endif
    4949
     50
     51const text_t OAI_EARLIESTTIMESTAMP_OID = "earliesttimestamp";
     52         // https://www.tutorialspoint.com/cplusplus/cpp_constants_literals.htm
    5053
    5154enum comerror_t {noError, authenticationFailure, protocolError,
     
    113116  text_tmap      dynamic_classifiers;
    114117  text_t         earliestDatestamp;   // For OAIserver validation. Time since linux Epoch, expressed as (long) integer value in string form
     118  // This field stored the builddate value from a collection's index/build.cfg file.
     119  // This field earliestDatestamp was used when oaiaction.calcEarliestDatestamp() needed to
     120  // determine the earliest timestamp of the repository, by selecting the earliestDatestamp among
     121  // all oai collections. Now it's no longer used by OAI, as that resorts to consulting oai-inf.db
     122  // of each collection, which has a collection's earliest timestamp stored, to work out the
     123  // earliest timestamp among all collections. But the build.cfg builddate stored in the
     124  // earliestDatestamp field may still be useful in future for some purpose, so leaving it alone.
     125 
    115126};
    116127
  • main/trunk/greenstone2/runtime-src/src/oaiservr/listidsaction.cpp

    r31387 r31903  
    237237  text_tset        metadata;
    238238  ofstream         logout("oai.log", ios::app);
     239    // logout closed automatically by object destructor at this method's end:
     240    // https://stackoverflow.com/questions/748014/do-i-need-to-manually-close-an-ifstream
    239241  text_t           lastModified = "";
    240242  text_t           deleted_status = "";
  • main/trunk/greenstone2/runtime-src/src/oaiservr/oaiaction.cpp

    r31390 r31903  
    551551}
    552552
     553// works out the earliest date/timestamp of the OAI repository,
     554// which compares and then selects the earliest timestamp value among all collections.
     555// In the past, the earliest date/timestamp used to be the unix epoch,
     556// later it became the earliest among each collection's builddate in build.cfg,
     557// and now, after implementing the OAI deletion policy, it needed to become the earliest
     558// among each collection's OAI_EARLIESTTIMESTAMP_OID record's timestamp value.
     559
    553560text_t oaiaction::calcEarliestDatestamp(recptproto *protocol, oaiargs &params) {
    554561   
     
    570577    // (the earliestDatestamp for a collection has already been extracted from
    571578    // their build.cfg file at this point by collectserver::configure. The field
    572     // is declared in comtypes.h)   
    573    
     579    // is declared in comtypes.h)
     580   
     581    // We've changed this again to grab the timestamp field of the OAI_EARLIESTTIMESTAMP_OID
     582    // record of each collection's oai-inf.db (representing the time that collection was
     583    // built for the very first time) and choosing the earliest among all of them.
    574584   
    575585    // Get a list of the OAI-enabled collections available
     
    597607            collection_iterator++;
    598608        }
     609
     610        ofstream         logout("oai.log", ios::app);
    599611       
    600612        // Now loop through the remaining collections
     
    604616            collection_name = (*collection_iterator);
    605617           
     618            text_tset        metadata;
     619            FilterResponse_t response;
     620
     621            // get timestamps from etc/oai-inf.<db> now, no longer from build.cfg
     622            // request the special record with OID=OAI_EARLIESTTIMESTAMP_OID for the collection
     623            bool status_ok = get_oai_info(OAI_EARLIESTTIMESTAMP_OID, collection_name, "", metadata, false, protocol, response, logout);
     624           
     625            if(status_ok) {
     626              ResultDocInfo_t doc_info = response.docInfo[0];
     627              text_t collEarliestTimestamp;
     628              // the timestamp we want lives in the "lastmodified" field of the OAI_EARLIESTTIMESTAMP_OID record
     629              this->getLastModifiedDate(doc_info, collEarliestTimestamp);
     630             
     631              if(earliestDatestamp == "") { // first earliestdatestamp we've seen for an oai collection
     632                earliestDatestamp = collEarliestTimestamp;
     633              } else if(collEarliestTimestamp < earliestDatestamp) {
     634                earliestDatestamp = collEarliestTimestamp;
     635              }
     636            } /*else { // collection may not have oai-inf.db (yet), check build.cfg?
     637                // No: no need to use the old way as fallback
     638               
    606639            ColInfoResponse_t cinfo;
    607640            comerror_t err;
     
    618651                }
    619652            }
     653              }
     654              */
    620655            collection_iterator++;
    621656           
    622         }       
     657        }
     658        logout.close();
    623659    }
    624660       
  • main/trunk/greenstone2/runtime-src/src/protocol/recptprototools.cpp

    r31387 r31903  
    3434// THIS FILE IS A CANDIDATE FOR REFACTORING: merge get_info methods
    3535
     36// overloaded, to allow "custom" filter options.
    3637bool get_info (const text_t &OID, const text_t &collection, const text_t &lang,
    3738           const text_tset &metadata, bool getParents,
     
    7677}
    7778
    78 // overloaded, to allow "custom" filter options.
    7979bool get_info (const text_t &OID, const text_t &collection, const text_t &lang,
    8080           const text_tset &metadata, const OptionValue_tarray &options,
Note: See TracChangeset for help on using the changeset viewer.