Index: main/trunk/greenstone2/runtime-src/src/colservr/collectserver.cpp
===================================================================
--- main/trunk/greenstone2/runtime-src/src/colservr/collectserver.cpp	(revision 24113)
+++ main/trunk/greenstone2/runtime-src/src/colservr/collectserver.cpp	(revision 24114)
@@ -291,4 +291,10 @@
     else if ((key == "auth_group") || (key == "auth_groups")) joinchar(cfgline,',',collectinfo.auth_group);
 
+	// build.cfg, earliestDatestamp of this collection needed for 
+	// OAIServer to work out earliestDatestamp of this repository
+	else if (key == "earliestdatestamp") {
+		collectinfo.earliestDatestamp = cfgline[0]; // get it from build.cfg
+	}
+	
     // store all the mappings for use when collection meta is read later
     // (build.cfg read before collect.cfg)
Index: main/trunk/greenstone2/runtime-src/src/colservr/comtypes.cpp
===================================================================
--- main/trunk/greenstone2/runtime-src/src/colservr/comtypes.cpp	(revision 24113)
+++ main/trunk/greenstone2/runtime-src/src/colservr/comtypes.cpp	(revision 24114)
@@ -62,4 +62,5 @@
   buildDate=0;
   buildType.clear();
+  earliestDatestamp.clear();
   numDocs=0;
   numSections=0;
Index: main/trunk/greenstone2/runtime-src/src/colservr/comtypes.h
===================================================================
--- main/trunk/greenstone2/runtime-src/src/colservr/comtypes.h	(revision 24113)
+++ main/trunk/greenstone2/runtime-src/src/colservr/comtypes.h	(revision 24114)
@@ -112,4 +112,5 @@
   text_tmap      private_documents;   // the acl to disallow access to listed documents
   text_tmap      dynamic_classifiers;
+  text_t		 earliestDatestamp;	  // For OAIserver validation. Time since linux Epoch, expressed as (long) integer value in string form
 };
 
Index: main/trunk/greenstone2/runtime-src/src/oaiservr/identifyaction.cpp
===================================================================
--- main/trunk/greenstone2/runtime-src/src/oaiservr/identifyaction.cpp	(revision 24113)
+++ main/trunk/greenstone2/runtime-src/src/oaiservr/identifyaction.cpp	(revision 24114)
@@ -26,4 +26,5 @@
 
 #include "identifyaction.h"
+#include "oaitools.h"
 
 bool identifyaction::validateAction(recptproto *protocol, oaiargs &params)
@@ -103,5 +104,71 @@
     // not to be worth the effort of trolling through all the lastmodified dates (by others with more 
     // say than me)
-    output << utf8convert << "  <earliestDatestamp>1970-01-01</earliestDatestamp>\n";
+	
+	// The above was before. However, now we mirror GS3 way of dealing with 
+	// earliestDatestamp by going through the earliestDatestamp field of each OAI 
+	// collection's build.cfg in order to work out earliestdatestamp of this Repository:
+	// by going through all the collections and getting the earliest among the
+	// "earliestDatestamp" values stored for each collection in its build.cfg
+	// (the earliestDatestamp for a collection has already been extracted from 
+	// their build.cfg file at this point by collectserver::configure. The field
+	// is declared in comtypes.h) 	
+	text_t earliestDatestamp = ""; // do not set default to unix epoch time "1970-01-01" yet
+	
+	// Get a list of the OAI-enabled collections available
+	text_tarray& collections = this->configuration->getCollectionsList();
+	if (collections.size() > 0)
+	{		
+		// get the identifier from the params
+		text_t identifier = params["identifier"];
+		text_t oai_OID_prefix = "oai:"+this->configuration->getRepositoryId()+":";
+		identifier.replace(oai_OID_prefix, "");
+
+		// Get the current collection from the identifier
+		text_t collection_name = "";
+		oaiclassifier::toGSDL(collection_name, identifier);
+
+		// Find the starting collection
+		text_tarray::iterator collection_iterator = collections.begin();
+		while (collection_iterator != collections.end())
+		{
+			if (collection_name == "" || collection_name == *collection_iterator)
+			{
+			  break;
+			}
+
+			collection_iterator++;
+		}
+		
+		// Now loop through the remaining collections
+		// to work out the earliest datestamp
+		while (collection_iterator != collections.end())
+		{
+			collection_name = (*collection_iterator);
+			
+			ColInfoResponse_t cinfo;
+			comerror_t err;	
+			protocol->get_collectinfo(collection_name, cinfo, err, cerr);
+			if (err == noError) {				
+				text_t eDatestamp = cinfo.earliestDatestamp;
+				time_t raw_time = (time_t)eDatestamp.getint();
+				eDatestamp = this->parseDatestamp(raw_time);
+				
+				if(earliestDatestamp == "") { // first earliestdatestamp we've seen for an oai collection
+					earliestDatestamp = eDatestamp;
+				} else if(eDatestamp < earliestDatestamp) {
+					earliestDatestamp = eDatestamp;
+				}				
+			}
+			collection_iterator++;
+			
+		}		
+	}
+	
+	// if repository's earliestDatestamp is still unset, default to unix epoch time
+	if(earliestDatestamp == "") { 
+		earliestDatestamp = "1970-01-01";
+	}	
+	
+    output << utf8convert << "  <earliestDatestamp>"<< earliestDatestamp <<"</earliestDatestamp>\n";
     output << utf8convert << "  <deletedRecord>no</deletedRecord>\n";
     output << utf8convert << "  <granularity>YYYY-MM-DD</granularity>\n";
Index: main/trunk/greenstone2/runtime-src/src/oaiservr/oaiconfig.cpp
===================================================================
--- main/trunk/greenstone2/runtime-src/src/oaiservr/oaiconfig.cpp	(revision 24113)
+++ main/trunk/greenstone2/runtime-src/src/oaiservr/oaiconfig.cpp	(revision 24114)
@@ -83,6 +83,5 @@
     if (!this->configureCollection(gsdlhome, *here)) {
       this->collectList.erase(here);
-    }
-    
+    }	
   }
   else {
@@ -119,8 +118,17 @@
   if (!file_exists(cnfgfile)) {
     return false;
-  }
+  }  
+  
   this->collection = gsdlcollect;
   this->read_configfile(cnfgfile);
-
+  
+  // to work out the earliestDatestamp for the repository, need to
+  // to read in the build.cfg file of each OAI collection, in order to
+  // find the oldest earliestDatestamp field of all the OAI collections
+  text_t buildcnfgfile = filename_cat(gsdlhome, "collect", gsdlcollect, "index", "build.cfg");
+  if (file_exists(buildcnfgfile)) {
+	this->read_configfile(buildcnfgfile);
+  }
+  
   return true;
 }
@@ -309,6 +317,6 @@
     this->oaiVersion = cfgline[0];
   }
-  
-}
+}
+
 
 text_t oaiconfig::generateBaseServerURL() {
