Changeset 23938 for main/trunk/greenstone3/src/java/org/greenstone/gsdl3
- Timestamp:
- 2011-04-20T21:02:12+12:00 (13 years ago)
- Location:
- main/trunk/greenstone3/src/java/org/greenstone/gsdl3
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/collection/Collection.java
r23901 r23938 68 68 /** time when this collection was built */ 69 69 protected long lastmodified = 0; 70 70 /** earliestDatestamp of this collection. Necessary for OAI */ 71 protected long earliestDatestamp = 0; 72 73 71 74 /** An element containing the serviceRackList element of buildConfig.xml, used to determine whether it contains 72 75 * the OAIPMH serviceRack … … 133 136 return is_public; 134 137 } 135 //used by the OAIReceptionist to find out the earliest datestamp amongst all oai collections in the repository 138 // Not used anymore by the OAIReceptionist to find out the earliest datestamp 139 // amongst all oai collections in the repository. May be useful generally. 136 140 public long getLastmodified() { 137 141 return lastmodified; 138 142 } 143 //used by the OAIReceptionist to find out the earliest datestamp amongst all oai collections in the repository 144 public long getEarliestDatestamp() { 145 return earliestDatestamp; 146 } 147 139 148 /** whether the service_map in ServiceCluster.java contains the service 'OAIPMH' 140 149 * 11/06/2007 xiao … … 179 188 build_config_elem = build_config_doc.getDocumentElement(); 180 189 } 181 190 182 191 lastmodified = build_config_file.lastModified(); 183 192 … … 264 273 } else { 265 274 has_oai = true; 275 276 // extract earliestDatestamp from the buildconfig.xml for OAI 277 Element metadata_list = (Element)GSXML.getChildByTagName(build_config_xml, GSXML.METADATA_ELEM+GSXML.LIST_MODIFIER); 278 279 if(metadata_list != null) { 280 NodeList children = metadata_list.getElementsByTagName(GSXML.METADATA_ELEM); 281 // can't do getChildNodes(), because whitespace, such as newlines, creates Text nodes 282 for (int i = 0; i < children.getLength(); i++) { 283 Element metadata = (Element)children.item(i); 284 if(metadata.getAttribute(GSXML.NAME_ATT).equals(OAIXML.EARLIEST_DATESTAMP)) { 285 String earliestDatestampStr = GSXML.getValue(metadata); 286 if(!earliestDatestampStr.equals("")) { 287 earliestDatestamp = Long.parseLong(earliestDatestampStr); 288 } 289 break; // found a metadata element with name=earliestDatestamp in buildconfig 290 } 291 } 292 } 293 294 // If at the end of this, there is no value for earliestDatestamp, print out a warning 295 logger.warn("No earliestDatestamp in buildConfig.xml for collection: " + this.cluster_name + ". Defaulting to 0."); 296 266 297 } 267 298 } else { // no list of services (no ServiceRackList), so no oai_service_rack either -
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/core/MessageRouter.java
r23793 r23938 621 621 //The collection name is returned as site_name:coll_name, which is in fact the set specification 622 622 ane.setAttribute(GSXML.NAME_ATT, site_name + ":" + col_name); 623 ane.setAttribute(OAIXML.LASTMODIFIED, "" + c.getLastmodified()); 624 623 ane.setAttribute(OAIXML.LASTMODIFIED, "" + c.getLastmodified()); 624 // lastmodified not of use anymore for OAI, perhaps useful as general information 625 ane.setAttribute(OAIXML.EARLIEST_DATESTAMP, "" + c.getEarliestDatestamp()); // for OAI 626 625 627 this.oai_collection_list.appendChild(ane); 626 628 //logger.info(GSXML.xmlNodeToString(oai_collection_list)); -
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/core/OAIReceptionist.java
r23913 r23938 296 296 * Use the time value plus the current system time to get the expiration date string. 297 297 */ 298 String expiration_date = OAIXML.getTime(System.currentTimeMillis() + OAIXML.getTokenExpiration()); 298 String expiration_date = OAIXML.getTime(System.currentTimeMillis() + OAIXML.getTokenExpiration()); // in milliseconds 299 299 token.setAttribute(OAIXML.EXPIRATION_DATE, expiration_date); 300 300 } … … 1034 1034 // See OAIConfig.xml 1035 1035 // dynamically works out what the earliestDateStamp is, since it varies by collection 1036 // returns this time in *milliseconds*. 1036 1037 protected long getEarliestDateStamp(NodeList oai_coll) { 1037 1038 //do the earliestDatestamp 1038 long lastmodified= System.currentTimeMillis();1039 long earliestDatestamp = System.currentTimeMillis(); 1039 1040 int oai_coll_size = oai_coll.getLength(); 1040 1041 if (oai_coll_size == 0) { 1041 1042 logger.info("returned oai collection list is empty. Setting repository earliestDatestamp to be 1970-01-01."); 1042 lastmodified= 0;1043 earliestDatestamp = 0; 1043 1044 } 1044 //the collection build time is determined by the last modified time of the buildConfig.xml file 1045 // the earliestDatestamp is now stored as a metadata element in the collection's buildConfig.xml file 1046 // we get the earliestDatestamp among the collections 1045 1047 for(int i=0; i<oai_coll_size; i++) { 1046 long coll_ build_time = Long.parseLong(((Element)oai_coll.item(i)).getAttribute(OAIXML.LASTMODIFIED));1047 lastmodified = (lastmodified > coll_build_time)? coll_build_time : lastmodified;1048 long coll_earliestDatestamp = Long.parseLong(((Element)oai_coll.item(i)).getAttribute(OAIXML.EARLIEST_DATESTAMP)); 1049 earliestDatestamp = (earliestDatestamp > coll_earliestDatestamp)? coll_earliestDatestamp : earliestDatestamp; 1048 1050 } 1049 return lastmodified; 1051 1052 return earliestDatestamp*1000; // converting from seconds to milliseconds 1050 1053 } 1051 1054 } -
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/OAIPMH.java
r23922 r23938 253 253 254 254 ArrayList keys = new ArrayList(info.getKeys()); 255 String lastmodified = "";256 if(keys.contains(OAIXML. LASTMODIFIED)) {257 lastmodified = info.getInfo(OAIXML.LASTMODIFIED);258 lastmodified = OAIXML.getTime(Long.parseLong(lastmodified)*1000); // java wants dates in milliseconds255 String oailastmodified = ""; 256 if(keys.contains(OAIXML.OAI_LASTMODIFIED)) { 257 oailastmodified = info.getInfo(OAIXML.OAI_LASTMODIFIED); 258 oailastmodified = OAIXML.getTime(Long.parseLong(oailastmodified)*1000); // java wants dates in milliseconds 259 259 } 260 260 … … 262 262 Element record = OAIXML.createElement(OAIXML.RECORD); 263 263 //compose the header element 264 record.appendChild(createHeaderElement(oid, lastmodified));264 record.appendChild(createHeaderElement(oid, oailastmodified)); 265 265 //compose the metadata element 266 266 record.appendChild(createMetadataElement(prefix, info, metadata_format)); … … 332 332 } 333 333 ArrayList keys = new ArrayList(info.getKeys()); 334 String lastmodified = "";335 if(keys.contains(OAIXML. LASTMODIFIED)) {336 lastmodified = info.getInfo(OAIXML.LASTMODIFIED);337 lastmodified = OAIXML.getTime(Long.parseLong(lastmodified)*1000); // java wants dates in milliseconds334 String oailastmodified = ""; 335 if(keys.contains(OAIXML.OAI_LASTMODIFIED)) { 336 oailastmodified = info.getInfo(OAIXML.OAI_LASTMODIFIED); 337 oailastmodified = OAIXML.getTime(Long.parseLong(oailastmodified)*1000); // java wants dates in milliseconds 338 338 } 339 339 340 Date this_date = OAIXML.getDate( lastmodified);340 Date this_date = OAIXML.getDate(oailastmodified); 341 341 if (from_date != null) { 342 342 if(this_date.before(from_date)) { … … 350 350 } 351 351 //compose the header element and append it 352 list_identifiers.appendChild(createHeaderElement(oid, lastmodified));352 list_identifiers.appendChild(createHeaderElement(oid, oailastmodified)); 353 353 }//end of for(int i=0; i<oid_list.size(); i++) of doing thru each record 354 354 … … 418 418 } 419 419 ArrayList keys = new ArrayList(info.getKeys()); 420 String lastmodified = "";421 if(keys.contains(OAIXML. LASTMODIFIED)) {422 lastmodified = info.getInfo(OAIXML.LASTMODIFIED);423 lastmodified = OAIXML.getTime(Long.parseLong(lastmodified)*1000); // java wants dates in milliseconds420 String oailastmodified = ""; 421 if(keys.contains(OAIXML.OAI_LASTMODIFIED)) { 422 oailastmodified = info.getInfo(OAIXML.OAI_LASTMODIFIED); 423 oailastmodified = OAIXML.getTime(Long.parseLong(oailastmodified)*1000); // java wants dates in milliseconds 424 424 } 425 425 426 Date this_date = OAIXML.getDate( lastmodified);426 Date this_date = OAIXML.getDate(oailastmodified); 427 427 if (from_date != null) { 428 428 if(this_date.before(from_date)) { … … 439 439 list_records.appendChild(record); 440 440 //compose the header element 441 record.appendChild(createHeaderElement(oid, lastmodified));441 record.appendChild(createHeaderElement(oid, oailastmodified)); 442 442 //compose the metadata element 443 443 record.appendChild(createMetadataElement(prefix, info, metadata_format)); … … 501 501 /** create a header element used when processing requests like ListRecords/GetRecord/ListIdentifiers 502 502 */ 503 private Element createHeaderElement(String oid, String lastmodified) {503 private Element createHeaderElement(String oid, String oailastmodified) { 504 504 Element header = OAIXML.createElement(OAIXML.HEADER); 505 505 Element identifier = OAIXML.createElement(OAIXML.IDENTIFIER); … … 510 510 header.appendChild(set_spec); 511 511 Element datestamp = OAIXML.createElement(OAIXML.DATESTAMP); 512 GSXML.setNodeText(datestamp, lastmodified);512 GSXML.setNodeText(datestamp, oailastmodified); 513 513 header.appendChild(datestamp); 514 514 return header; … … 656 656 <contains>".1;".2;".3;".4;".5;".6;".7;".8;".9 657 657 <docnum>349 658 <oailastmodified>1303283795 659 <lastmodifieddate>20110412 660 <oailastmodifieddate>20110420 658 661 ---------------------------------------------------------------------- 659 662 */ -
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/OAIXML.java
r23922 r23938 112 112 public static final String OAI = "OAI"; 113 113 public static final String OAI_DASH_PMH = "OAI-PMH"; 114 public static final String OAI_LASTMODIFIED = "oailastmodified"; 114 115 public static final String OAIPMH = "OAIPMH"; 115 116 public static final String OAI_RESUMPTION_TOKENS = "OAIResumptionTokens";
Note:
See TracChangeset
for help on using the changeset viewer.