Changeset 23922

Show
Ignore:
Timestamp:
18.04.2011 19:39:15 (9 years ago)
Author:
ak19
Message:

Two fixes: 1. Dr Bainbridge noticed the Date object used in OAIXML.java's getTime() accepted time in milliseconds, not seconds as the long parameter contained when called from OAIPMH (other classes calling OAIXML.getTime() called it correctly in milliseconds. 2. Fixed error in OAIServer.getPost where I wasn't resetting the new member variable queryString, which was breaking future doGet requests.

Location:
main/trunk/greenstone3/src/java/org/greenstone/gsdl3
Files:
3 modified

Legend:

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

    r23913 r23922  
    288288    // if called by doPost (if this was originally a POST request), var queryString would have been set 
    289289    String query = (queryString == null) ? request.getQueryString() : queryString; 
     290    queryString = null; // reset member variable, else no doGet will work as long as the server remains running 
     291 
    290292    String[] pairs = (query==null)? null : query.split("&");//split into key/value pairs 
    291293    String verb = getVerb(query); 
     
    413415      if(queryString.length() > 0) { 
    414416      queryString = queryString.substring(1); 
    415       //queryString = java.net.URLEncoder.encode(queryString,"UTF-8"); 
     417      //queryString = OAIXML.oaiEncode(queryString); 
    416418      } 
    417419      if(queryString.equals("")) { 
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/OAIPMH.java

    r22974 r23922  
    256256    if(keys.contains(OAIXML.LASTMODIFIED)) { 
    257257      lastmodified = info.getInfo(OAIXML.LASTMODIFIED); 
    258     } 
    259     lastmodified = OAIXML.getTime(Long.parseLong(lastmodified)); 
     258      lastmodified = OAIXML.getTime(Long.parseLong(lastmodified)*1000); // java wants dates in milliseconds 
     259    } 
    260260 
    261261    Element get_record = OAIXML.createElement(OAIXML.GET_RECORD); 
     
    335335      if(keys.contains(OAIXML.LASTMODIFIED)) { 
    336336        lastmodified = info.getInfo(OAIXML.LASTMODIFIED); 
    337       } 
    338       lastmodified = OAIXML.getTime(Long.parseLong(lastmodified)); 
     337    lastmodified = OAIXML.getTime(Long.parseLong(lastmodified)*1000); // java wants dates in milliseconds 
     338      } 
    339339       
    340340      Date this_date = OAIXML.getDate(lastmodified);         
     
    421421      if(keys.contains(OAIXML.LASTMODIFIED)) { 
    422422        lastmodified = info.getInfo(OAIXML.LASTMODIFIED); 
    423       } 
    424       lastmodified = OAIXML.getTime(Long.parseLong(lastmodified)); 
     423    lastmodified = OAIXML.getTime(Long.parseLong(lastmodified)*1000); // java wants dates in milliseconds 
     424      } 
    425425       
    426426      Date this_date = OAIXML.getDate(lastmodified);         
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/OAIXML.java

    r23913 r23922  
    239239        Element token_elem = (Element)tokens.item(i); 
    240240        String expire_str = token_elem.getAttribute(EXPIRATION_DATE); 
    241         long datestamp = getTime(expire_str); 
     241        long datestamp = getTime(expire_str); // expire_str is in milliseconds 
    242242        if(datestamp < System.currentTimeMillis()) { 
    243243          resumption_token_elem.removeChild(token_elem); 
     
    360360     
    361361    public static long getTokenExpiration() { 
    362       return token_expiration*1000; 
     362    return token_expiration*1000; // in milliseconds 
    363363    } 
    364364 
     
    520520    /** get the string representation of a time from a long value(long type) 
    521521     */ 
    522     public static String getTime(long seconds) { 
    523       Date date = new Date(seconds); 
     522    public static String getTime(long milliseconds) { 
     523      Date date = new Date(milliseconds); 
    524524      SimpleDateFormat sdf = new SimpleDateFormat(granularity); 
    525525      return sdf.format(date);