Fix for ETHREEOH-274 and handling of potentially missing cm:modifiedDate property in DownloadContentServlet.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@11254 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Kevin Roast
2008-10-08 11:22:17 +00:00
parent 7031037e2f
commit 0c66da37c5
2 changed files with 47 additions and 22 deletions

View File

@@ -243,20 +243,23 @@ public abstract class BaseDownloadContentServlet extends BaseServlet
// check If-Modified-Since header and set Last-Modified header as appropriate
Date modified = (Date)nodeService.getProperty(nodeRef, ContentModel.PROP_MODIFIED);
long modifiedSince = req.getDateHeader("If-Modified-Since");
if (modifiedSince > 0L)
if (modified != null)
{
// round the date to the ignore millisecond value which is not supplied by header
long modDate = (modified.getTime() / 1000L) * 1000L;
if (modDate <= modifiedSince)
long modifiedSince = req.getDateHeader("If-Modified-Since");
if (modifiedSince > 0L)
{
if (logger.isDebugEnabled())
logger.debug("Returning 304 Not Modified.");
res.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
return;
// round the date to the ignore millisecond value which is not supplied by header
long modDate = (modified.getTime() / 1000L) * 1000L;
if (modDate <= modifiedSince)
{
if (logger.isDebugEnabled())
logger.debug("Returning 304 Not Modified.");
res.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
return;
}
}
res.setDateHeader("Last-Modified", modified.getTime());
}
res.setDateHeader("Last-Modified", modified.getTime());
if (attachment == true)
{