Ignore:
Timestamp:
2011-04-16T20:16:19+12:00 (13 years ago)
Author:
ak19
Message:

Additional changes to succeed in more of the OAIServer validation tests: 1. Now passes POST requests introduced in OAI version 2.0. 2. Passes further error tests regarding handling of erroneous parameters for From and/or Until dates and ResumptionToken. More (major) changes yet to be made to pass the final official OAIServer validation test: to do with earliestDateStamp.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/OAIXML.java

    r23862 r23913  
    161161    //stores the date format "yyyy-MM-ddTHH:mm:ssZ"
    162162    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
    163170    //this value is overriden in getOAIConfigXML()
    164171    public static long token_expiration = 7200;
     
    312319      //initialize the granu_str which might be used by other methods (eg, getDate())
    313320      granularity = GSXML.getNodeText(granu_elem).trim();
     321
    314322      //change "yyyy-MM-ddTHH:mm:ssZ" to "yyyy-MM-dd'T'HH:mm:ss'Z'"
    315323      granularity = granularity.replaceAll("T", "'T'");
     
    462470        date = sdf.parse(pattern);
    463471      } 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      }
    466486      }
    467487      return date;
     
    481501        date = sdf.parse(pattern);
    482502      } 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      }       
    485517      }
    486518      return date.getTime();
Note: See TracChangeset for help on using the changeset viewer.