Changeset 31911

Show
Ignore:
Timestamp:
21.08.2017 15:38:19 (3 months ago)
Author:
ak19
Message:

First part of commit after using earliestDatestamp from oai-inf.db rather than build conf: 1. skip output of OAI records for internal 'OID' stored in oai-inf.db, whose entry represents the collection's earliest timestamp info. 2. Now prefer doc's lastmod date from oai-inf.db to doc's oailastmod date in indedb. So for all records, not just deleted records that only have entries in oaiinfdb and not indexdb.

Location:
main/trunk/greenstone3/src/java/org/greenstone/gsdl3
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/OAIPMH.java

    r31580 r31911  
    368368        logger.warn("OID: " + oid + " is not present in the collection's oai-inf database."); 
    369369    } else  { 
     370 
     371        // indexdb doesn't have info on deleted docs, only oaiinf db does. 
     372        // So only oaiinfdb has timestamps for deleted docs 
     373        // For non-deleted doc ids: also obtain timestamp from oaiinf db,  
     374        // but if the oaiinf db doesn't exist, resort to oailastmodified fields of indexdb. 
     375        String timestamp = oai_info.getInfo(OAIXML.OAI_INF_TIMESTAMP); // stored in seconds, like oailastmodified in the collection index db 
     376        millis = Long.parseLong(timestamp)*1000; // in milliseconds      
     377         
    370378        String oaiinf_status = oai_info.getInfo(OAIXML.OAI_INF_STATUS); 
    371379        if(oaiinf_status != null && oaiinf_status.equals(OAIXML.OAI_INF_DELETED)) { 
    372380        OID_is_deleted = true; 
    373  
    374         // get the right timestamp for deletion: from oaiinf db 
    375         String timestamp = oai_info.getInfo(OAIXML.OAI_INF_TIMESTAMP); // in seconds presumably, like oailastmodified in the collection index db         
    376          
    377         millis = Long.parseLong(timestamp)*1000; // in milliseconds 
    378381        } 
    379382    } 
     
    384387    DBInfo info = this.coll_db.getInfo(oid); 
    385388    if (info == null) { 
    386       logger.error("OID: " + oid + " is not present in the collection database."); 
    387       //return OAIXML.createErrorResponse(OAIXML.ID_DOES_NOT_EXIST, ""); // not an error: may exist as deleted (marked 'D') in oai-inf db 
    388     } 
    389     else if (millis == -1) { // so !OID_is_deleted, get oailastmodified from collection's index db 
    390     ArrayList<String> keys = new ArrayList<String>(info.getKeys());  
     389    if(!OID_is_deleted) { // we don't expect to find entries for deleted docs in index db. 
     390        logger.error("OID: " + oid + " is not present in the collection index database."); 
     391        return OAIXML.createErrorResponse(OAIXML.ID_DOES_NOT_EXIST, ""); 
     392    } // if doc deleted, id missing in indexdb is not an error: doc id would exist only in oai-inf db, marked as deleted 'D' 
     393    } 
     394    else if (millis == -1) { // so couldn't get doc lastmod from oaiinf db, get oailastmodified from collection's index db 
    391395    millis = getDateStampMillis(info);   
    392396    } 
     
    494498    for(int i=0; i<oid_list.size(); i++) { 
    495499      String oid = oid_list.get(i); 
     500 
     501      if(oid.equals(OAIXML.OAI_EARLIEST_TIMESTAMP_OID)) { // internal id not doc id, so skip 
     502      continue; 
     503      } 
     504       
    496505      boolean OID_is_deleted = false; 
    497506      long millis = -1; 
     
    503512          logger.warn("OID: " + oid + " is not present in the collection's oai-inf database."); 
    504513      } else  { 
     514           
     515          // indexdb doesn't have info on deleted docs, only oaiinf db does. 
     516          // So only oaiinfdb has timestamps for deleted docs 
     517          // For non-deleted doc ids: also obtain timestamp from oaiinf db,  
     518          // but if the oaiinf db doesn't exist, resort to oailastmodified fields of indexdb. 
     519          String timestamp = oai_info.getInfo(OAIXML.OAI_INF_TIMESTAMP); // stored in seconds like oailastmodified in the collection index db          
     520          millis = Long.parseLong(timestamp)*1000; // in milliseconds 
     521           
    505522          String oaiinf_status = oai_info.getInfo(OAIXML.OAI_INF_STATUS); 
    506523          if(oaiinf_status != null && oaiinf_status.equals(OAIXML.OAI_INF_DELETED)) { 
    507524          OID_is_deleted = true; 
    508            
    509           // get the right timestamp for deletion: from oaiinf db 
    510           String timestamp = oai_info.getInfo(OAIXML.OAI_INF_TIMESTAMP); // in seconds presumably, like oailastmodified in the collection index db       
    511            
    512           millis = Long.parseLong(timestamp)*1000; // in milliseconds 
    513525          } 
    514526      } 
     
    516528      DBInfo info = this.coll_db.getInfo(oid); 
    517529      if (info == null) { // can happen if oid was deleted, in which case only oai_info keeps a record of the oid 
    518         logger.error("Collection database does not contain information about oid: " +oid); 
    519       } 
    520       else if (millis == -1) { // so !OID_is_deleted, get oailastmodified from collection's index db 
     530      if(!OID_is_deleted) { // we don't expect to find entries for deleted docs in index db. 
     531          logger.error("Collection database does not contain information about oid: " +oid); 
     532      } 
     533      } 
     534      else if (millis == -1) { // so couldn't get doc lastmod from oaiinf db, get oailastmodified from collection's index db 
    521535       
    522536      millis = getDateStampMillis(info); 
     
    524538 
    525539      Date this_date = null; 
     540      String oailastmodified = (millis == -1) ? "" : OAIXML.getTime(millis); 
     541       
    526542      if (millis == -1) { 
    527543      if (from_date != null || until_date !=null) { 
     
    544560       
    545561      //compose the header element, which we'll be appending no matter what 
    546       Element header = createHeaderElement(doc, oid, OAIXML.getTime(millis), OID_is_deleted); 
     562      Element header = createHeaderElement(doc, oid, oailastmodified, OID_is_deleted); 
    547563 
    548564      if (include_metadata) { // doing ListRecords 
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/OAIXML.java

    r31230 r31911  
    7878  public static final String RESPONSE_DATE = "responseDate"; 
    7979  public static final String REQUEST = "request"; 
    80    
     80 
     81  // internal "OID" identifiers in the oai-inf db 
     82  /** represents the timestamp of the OAI collection (when its oai-inf db was first created) */ 
     83  public static final String OAI_EARLIEST_TIMESTAMP_OID = "_earliesttimestamp";   
     84     
    8185  // Identify data 
    8286  public static final String ADMIN_EMAIL = "adminEmail";