Changeset 29267
- Timestamp:
- 2014-09-11T13:32:53+12:00 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/OAIPMH.java
r29067 r29267 345 345 Document doc = XMLConverter.newDOM(); 346 346 ArrayList<String> keys = new ArrayList<String>(info.getKeys()); 347 String oailastmodified = info.getInfo(OAIXML.OAI_LASTMODIFIED);348 if (!oailastmodified.equals("")) {349 // format into a string350 oailastmodified = OAIXML.getTime( Long.parseLong(oailastmodified)*1000); // java wants dates in milliseconds347 long millis = getDateStampMillis(info); 348 String oailastmodified = ""; 349 if (millis != -1) { 350 oailastmodified = OAIXML.getTime(millis); 351 351 } 352 352 … … 444 444 } 445 445 446 String oailastmodified = info.getInfo(OAIXML.OAI_LASTMODIFIED); 447 long oailastmodifiedmillis = 0; 446 long millis = getDateStampMillis(info); 448 447 Date this_date = null; 449 if ( oailastmodified.equals("")) {448 if (millis == -1) { 450 449 if (from_date != null || until_date !=null) { 451 450 continue; // if this doc doesn't have a date for some reason, and 452 451 // we are doing a date range, then don't include it. 453 452 } 454 } else { // check the date against date range from query (if any) 455 oailastmodifiedmillis = Long.parseLong(oailastmodified)*1000; // greenstone dates are in secods, and Java wants dates in milliseconds 456 this_date = new Date(oailastmodifiedmillis); 457 453 } else { 454 this_date = new Date(millis); 458 455 if (from_date != null) { 459 456 if(this_date.before(from_date)) { … … 467 464 } 468 465 } 466 469 467 //Now check that this id has metadata for the required prefix. 470 468 if (documentContainsMetadata(info, set_of_elems)) { … … 475 473 list_items.appendChild(record); 476 474 //compose the header element 477 record.appendChild(createHeaderElement(doc, oid, OAIXML.getTime( oailastmodifiedmillis)));475 record.appendChild(createHeaderElement(doc, oid, OAIXML.getTime(millis))); 478 476 //compose the metadata element 479 477 record.appendChild(createMetadataElement(doc, prefix, info)); 480 478 } else { 481 479 //compose the header element and append it 482 list_items.appendChild(createHeaderElement(doc, oid, OAIXML.getTime( oailastmodifiedmillis)));480 list_items.appendChild(createHeaderElement(doc, oid, OAIXML.getTime(millis))); 483 481 } 484 482 } // otherwise we won't include this oid. … … 741 739 } 742 740 741 protected long getDateStampMillis(DBInfo info) { 742 // gs.OAIDateStamp is in YYYY-MM-DD 743 String time_stamp = info.getInfo(OAIXML.GS_OAI_DATE_STAMP); 744 long millis = -1; 745 if (!time_stamp.equals("")) { 746 millis = OAIXML.getTime(time_stamp); 747 } 748 if (millis == -1) { 749 // oailastmodified is in seconds 750 time_stamp = info.getInfo(OAIXML.OAI_LASTMODIFIED); 751 if (!time_stamp.equals("")) { 752 millis = Long.parseLong(time_stamp)*1000; 753 } 754 } 755 return millis; 756 757 758 } 743 759 } 744 760
Note:
See TracChangeset
for help on using the changeset viewer.