Changeset 24114


Ignore:
Timestamp:
06/03/11 22:44:28 (10 years ago)
Author:
ak19
Message:

Now GS2 works out the earliestDatestamp of the repository in the manner GS3 does it (read each OAI-enabled collection's build.cfg to get the collection's earliestDatestamp field and choose the oldest such date among the OAI collections). Previously GS2 used to always set the earliestDatestamp to the unix epoch of 1970, which, while it would validate, wasn't the right thing to do as it wouldn't help with resumptiontokens and other date based things. Checked that the GS server still validates.

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

Legend:

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

    r23492 r24114  
    291291    else if ((key == "auth_group") || (key == "auth_groups")) joinchar(cfgline,',',collectinfo.auth_group);
    292292
     293    // build.cfg, earliestDatestamp of this collection needed for
     294    // OAIServer to work out earliestDatestamp of this repository
     295    else if (key == "earliestdatestamp") {
     296        collectinfo.earliestDatestamp = cfgline[0]; // get it from build.cfg
     297    }
     298   
    293299    // store all the mappings for use when collection meta is read later
    294300    // (build.cfg read before collect.cfg)
  • main/trunk/greenstone2/runtime-src/src/colservr/comtypes.cpp

    r15416 r24114  
    6262  buildDate=0;
    6363  buildType.clear();
     64  earliestDatestamp.clear();
    6465  numDocs=0;
    6566  numSections=0;
  • main/trunk/greenstone2/runtime-src/src/colservr/comtypes.h

    r22050 r24114  
    112112  text_tmap      private_documents;   // the acl to disallow access to listed documents
    113113  text_tmap      dynamic_classifiers;
     114  text_t         earliestDatestamp;   // For OAIserver validation. Time since linux Epoch, expressed as (long) integer value in string form
    114115};
    115116
  • main/trunk/greenstone2/runtime-src/src/oaiservr/identifyaction.cpp

    r22739 r24114  
    2626
    2727#include "identifyaction.h"
     28#include "oaitools.h"
    2829
    2930bool identifyaction::validateAction(recptproto *protocol, oaiargs &params)
     
    103104    // not to be worth the effort of trolling through all the lastmodified dates (by others with more
    104105    // 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";
    106173    output << utf8convert << "  <deletedRecord>no</deletedRecord>\n";
    107174    output << utf8convert << "  <granularity>YYYY-MM-DD</granularity>\n";
  • main/trunk/greenstone2/runtime-src/src/oaiservr/oaiconfig.cpp

    r23233 r24114  
    8383    if (!this->configureCollection(gsdlhome, *here)) {
    8484      this->collectList.erase(here);
    85     }
    86    
     85    }   
    8786  }
    8887  else {
     
    119118  if (!file_exists(cnfgfile)) {
    120119    return false;
    121   }
     120  } 
     121 
    122122  this->collection = gsdlcollect;
    123123  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 
    125133  return true;
    126134}
     
    309317    this->oaiVersion = cfgline[0];
    310318  }
    311  
    312 }
     319}
     320
    313321
    314322text_t oaiconfig::generateBaseServerURL() {
Note: See TracChangeset for help on using the changeset viewer.