- Timestamp:
- 2011-04-16T20:16:19+12:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/OAIXML.java
r23862 r23913 161 161 //stores the date format "yyyy-MM-ddTHH:mm:ssZ" 162 162 public static String granularity = ""; 163 164 // http://www.openarchives.org/OAI/openarchivesprotocol.html#DatestampsRequests 165 // specifies that all repositories must support YYYY-MM-DD (yyyy-MM-dd in Java) 166 // this would be in addition to the other (optional) granularity of above that 167 // a repository may additionally choose to support. 168 public static final String default_granularity = "yyyy-MM-dd"; 169 163 170 //this value is overriden in getOAIConfigXML() 164 171 public static long token_expiration = 7200; … … 312 319 //initialize the granu_str which might be used by other methods (eg, getDate()) 313 320 granularity = GSXML.getNodeText(granu_elem).trim(); 321 314 322 //change "yyyy-MM-ddTHH:mm:ssZ" to "yyyy-MM-dd'T'HH:mm:ss'Z'" 315 323 granularity = granularity.replaceAll("T", "'T'"); … … 462 470 date = sdf.parse(pattern); 463 471 } catch(Exception e) { 464 logger.error("invalid date format: " + pattern); 465 return null; 472 if(!default_granularity.equals(granularity)) { // try validating against default granularity 473 try { 474 date = null; 475 sdf = null; 476 sdf = new SimpleDateFormat(default_granularity); 477 date = sdf.parse(pattern); 478 } catch(Exception ex) { 479 logger.error("invalid date format: " + pattern); 480 return null; 481 } 482 } else { 483 logger.error("invalid date format: " + pattern); 484 return null; 485 } 466 486 } 467 487 return date; … … 481 501 date = sdf.parse(pattern); 482 502 } catch(Exception e) { 483 logger.error("invalid date format: " + pattern); 484 return -1; 503 if(!default_granularity.equals(granularity)) { // try validating against default granularity 504 try { 505 date = null; 506 sdf = null; 507 sdf = new SimpleDateFormat(default_granularity); 508 date = sdf.parse(pattern); 509 } catch(Exception ex) { 510 logger.error("invalid date format: " + pattern); 511 return -1; 512 } 513 } else { 514 logger.error("invalid date format: " + pattern); 515 return -1; 516 } 485 517 } 486 518 return date.getTime();
Note:
See TracChangeset
for help on using the changeset viewer.