Changeset 31911
- Timestamp:
- 2017-08-21T15:38:19+12:00 (6 years ago)
- Location:
- main/trunk/greenstone3/src/java/org/greenstone/gsdl3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/OAIPMH.java
r31580 r31911 368 368 logger.warn("OID: " + oid + " is not present in the collection's oai-inf database."); 369 369 } 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 370 378 String oaiinf_status = oai_info.getInfo(OAIXML.OAI_INF_STATUS); 371 379 if(oaiinf_status != null && oaiinf_status.equals(OAIXML.OAI_INF_DELETED)) { 372 380 OID_is_deleted = true; 373 374 // get the right timestamp for deletion: from oaiinf db375 String timestamp = oai_info.getInfo(OAIXML.OAI_INF_TIMESTAMP); // in seconds presumably, like oailastmodified in the collection index db376 377 millis = Long.parseLong(timestamp)*1000; // in milliseconds378 381 } 379 382 } … … 384 387 DBInfo info = this.coll_db.getInfo(oid); 385 388 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 391 395 millis = getDateStampMillis(info); 392 396 } … … 494 498 for(int i=0; i<oid_list.size(); i++) { 495 499 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 496 505 boolean OID_is_deleted = false; 497 506 long millis = -1; … … 503 512 logger.warn("OID: " + oid + " is not present in the collection's oai-inf database."); 504 513 } 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 505 522 String oaiinf_status = oai_info.getInfo(OAIXML.OAI_INF_STATUS); 506 523 if(oaiinf_status != null && oaiinf_status.equals(OAIXML.OAI_INF_DELETED)) { 507 524 OID_is_deleted = true; 508 509 // get the right timestamp for deletion: from oaiinf db510 String timestamp = oai_info.getInfo(OAIXML.OAI_INF_TIMESTAMP); // in seconds presumably, like oailastmodified in the collection index db511 512 millis = Long.parseLong(timestamp)*1000; // in milliseconds513 525 } 514 526 } … … 516 528 DBInfo info = this.coll_db.getInfo(oid); 517 529 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 521 535 522 536 millis = getDateStampMillis(info); … … 524 538 525 539 Date this_date = null; 540 String oailastmodified = (millis == -1) ? "" : OAIXML.getTime(millis); 541 526 542 if (millis == -1) { 527 543 if (from_date != null || until_date !=null) { … … 544 560 545 561 //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); 547 563 548 564 if (include_metadata) { // doing ListRecords -
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/OAIXML.java
r31230 r31911 78 78 public static final String RESPONSE_DATE = "responseDate"; 79 79 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 81 85 // Identify data 82 86 public static final String ADMIN_EMAIL = "adminEmail";
Note:
See TracChangeset
for help on using the changeset viewer.