Ignore:
Timestamp:
2017-02-08T18:31:18+13:00 (7 years ago)
Author:
ak19
Message:

Round 1 of commits for getting OAI deletion policy to work with GS2 (server end). The perl code writing out the OAI db and the GS3 server code implementing the deletion policy had already been completed earlier (end 2016).

File:
1 edited

Legend:

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

    r27534 r31387  
    403403
    404404void oaiaction::output_record_header(ostream &output, const text_t &oaiLabel, const text_t &lastModified,
    405                      const text_tarray &memberOf, int oaiVersion)
    406 {
     405                     const text_t &deleted_status, const text_tarray &memberOf, int oaiVersion)
     406{
     407  if(deleted_status == "D") { // record marked as deleted
     408    output << "    <header status=\"deleted\">" << endl;
     409  } else { // deleted_status is "" or E for exists
    407410    output << "    <header>" << endl;
     411  }
    408412    output << "      <identifier>" << oaiLabel     << "</identifier>" << endl;
    409413    output << "      <datestamp>"  << lastModified << "</datestamp>" << endl;
     
    443447}
    444448
     449// Method that looks for the requested metaname in the doc_info, and if found, sets the value
     450// in the argument 'metavalue'.
     451void oaiaction::getMeta(ResultDocInfo_t &doc_info, const text_t &metaname, text_t &metavalue)
     452{
     453  text_t current_metaname;
     454
     455  //ofstream         logout("oai.log", ios::app);
     456
     457  MetadataInfo_tmap::iterator current = doc_info.metadata.begin();
     458  MetadataInfo_tmap::iterator end = doc_info.metadata.end();
     459
     460  while(current != end){
     461    current_metaname = current->first;
     462    lc(current_metaname); // lowercased for string comparison below
     463
     464    if (current_metaname == metaname && current->second.values.size() >= 1) { // found match with a value
     465      metavalue = current->second.values[0];
     466
     467      //logout << "Looking for metaname = " << current_metaname << endl;
     468      //logout << "\t\t\t Found value = " << metavalue << endl;
     469      return; // done
     470    }
     471
     472    ++current;
     473  }
     474
     475  //logout.close();
     476}
     477
    445478void oaiaction::getLastModifiedDate(ResultDocInfo_t &doc_info, text_t &lastModified)
    446479{
     
    460493    }
    461494    else{
    462       if (temp == "oailastmodified" && lastModified == "" && current->second.values.size() >= 1) {
    463     lastModified = current->second.values[0];
    464     time_t raw_time = (time_t)lastModified.getint();
    465     lastModified = this->parseDatestamp(raw_time);
     495      if(lastModified == "" && current->second.values.size() >= 1) {
     496
     497    if (temp == "oaiinf.timestamp") { // new way is to store oai timestamp in oai db and get it from there
     498      // check if there was a timestamp for the doc in the etc/oai-inf database
     499      lastModified = current->second.values[0];
     500   
     501    } else if (temp == "oailastmodified") { // old way, being phased out
     502      // check if there was an oailastmodified timestamp for the doc in the collection index db
     503      lastModified = current->second.values[0];
     504    }
     505
     506    if(lastModified != "") { // if we've now set the lastModified value, convert it for display and return
     507      time_t raw_time = (time_t)lastModified.getint();
     508      lastModified = this->parseDatestamp(raw_time);
     509   
     510      return;
     511    }
    466512      }
    467     }
     513    } // else keep looking for oai timestamp
    468514    ++current;
    469515  } 
     516
    470517}
    471518
     
    475522  FilterResponse_t response;
    476523  text_tset        metadata;
    477   bool status_ok = get_info(OID, collection, "", metadata, false, protocol, response, logout);
     524  bool status_ok = get_oai_info(OID, collection, "", metadata, false, protocol, response, logout);
     525     // get timestamp from etc/oai-inf.<db> now, no longer from index.db
    478526  bool not_too_early = false, not_too_recent = false;
    479527
Note: See TracChangeset for help on using the changeset viewer.