Hi Stuart and Monika, I've been working with this issue and this 
approach worked well with my DSpace instance:

- the date that DSpace stores as last modified has a big precision, and 
the date that we receive from the http header "Last-Modified" doesn't 
have precision enough (only with seconds), so when DSpace receives the 
LastModified date from the item in milliseconds is different from the 
date that gets from the http header in milliseconds.

- to avoid this issue I've created two Date classes and compare this 
objects with the methods "before" or "after" and worked well:

         if (isSpider)
         {
             // Check for if-modified-since header -- ONLY if not 
authenticated
             long modSince = request.getDateHeader("If-Modified-Since");

                 java.util.Date d1= new java.util.Date(modSince);
//            if (modSince != -1 && item != null && 
item.getLastModified().getTime() <= modSince)
             if (modSince != -1 && item != null && 
(item.getLastModified().toGMTString().equals(d1.toGMTString())||item.getLastModified().before(d1))
 
)
             {
                 // Item has not been modified since requested date,
                 // hence bitstream has not; return 304
                 response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
                 return;
             }
         }

If you have a look at the code you'll see that this only works if DSpace 
detects that this is a spider. To do this I tried with a curl request 
like this:

curl -v -A "Mozilla/5.0 (compatible; Googlebot/2.1; 
+http://www.google.com/bot.html)2011-05-19 10:53:08"  -z 'Wed, 13 Apr 
2011 00:32:26 GMT' 'http://.....sequence=1'

and it worked well.

I hope that this helps.

Best regards,

Jesús

On 05/09/2011 10:52 PM, Stuart Lewis wrote:
> Hi Monika,
>
>> There appears to be a problem with last modified handling of bitstreams
>>
>> For the bitstream
>> http://scholars.indstate.edu/bitstream/10484/108/1/Yazvac.pdf
>> the last modified is reported as Thu, 06 Jan 2011 17:54:26
>>
>> but requesting the stream with
>> curl -z 'Thu, 06 Jan 2011 17:54:26 GMT' 
>> http://scholars.indstate.edu/bitstream/10484/108/1/Yazvac.pdf
>> returns the bitstream itself
>>
>> curl realizes that the bitstream is unchanged when doing (date + 1second)
>> curl -z 'Thu, 06 Jan 2011 17:54:27 GMT' 
>> http://scholars.indstate.edu/bitstream/10484/108/1/Yazvac.pdf
>>
>> I found the same behavior for a bitstream from another DSPACE instance:
>> http://smartech.gatech.edu/bitstream/handle/1853/32992/museum_program.pdf?sequence=3
>>
>> It seems that the servlet may compare last modified dates with>= instead of>
>> Where can I check/fix this ?
> Take a look in:
>
>   - 
> dspace-jspui/dspace-jspui-api/src/main/java/org/dspace/app/webui/servlet/BitstreamServlet.java
>
> And look for the following code:
>
>              // Check for if-modified-since header
>              long modSince = request.getDateHeader("If-Modified-Since");
>
>              if (modSince != -1&&  item.getLastModified().getTime()<  
> modSince)
>              {
>                  // Item has not been modified since requested date,
>                  // hence bitstream has not; return 304
>                  response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
>                  return;
>              }
>
> That might be the bit to check.
>
> Last modified date for an item is based on the last date that the item was 
> modified (e.g. metadata updated, new file uploaded).
>
> Thanks,
>
>
> Stuart Lewis
> Digital Development Manager
> Te Tumu Herenga The University of Auckland Library
> Auckland Mail Centre, Private Bag 92019, Auckland 1142, New Zealand
> Ph: +64 (0)9 373 7599 x81928
>
>
> ------------------------------------------------------------------------------
> WhatsUp Gold - Download Free Network Management Software
> The most intuitive, comprehensive, and cost-effective network
> management toolset available today.  Delivers lowest initial
> acquisition cost and overall TCO of any competing solution.
> http://p.sf.net/sfu/whatsupgold-sd
> _______________________________________________
> DSpace-tech mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/dspace-tech


------------------------------------------------------------------------------
What Every C/C++ and Fortran developer Should Know!
Read this article and learn how Intel has extended the reach of its 
next-generation tools to help Windows* and Linux* C/C++ and Fortran 
developers boost performance applications - including clusters. 
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
DSpace-tech mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dspace-tech

Reply via email to