@Override public Long[] getResourceAttributes(String name, Context context) { Long[] result = new Long[2]; try { ResourceAttributes resource = (ResourceAttributes) context.getResources().getAttributes(name); result[0] = resource.getContentLength(); result[1] = resource.getLastModified(); } catch (NamingException ex) { logger.trace("", ex); } return result; }
/** * Check if the if-unmodified-since condition is satisfied. * * @param request The servlet request we are processing * @param response The servlet response we are creating * @param resourceInfo File object * @return boolean true if the resource meets the specified condition, * and false if the condition is not satisfied, in which case request * processing is stopped */ protected boolean checkIfUnmodifiedSince(HttpServletRequest request, HttpServletResponse response, ResourceAttributes resourceAttributes) throws IOException { try { long lastModified = resourceAttributes.getLastModified(); long headerValue = request.getDateHeader("If-Unmodified-Since"); if (headerValue != -1) { if ( lastModified >= (headerValue + 1000)) { // The entity has not been modified since the date // specified by the client. This is not an error case. response.sendError(HttpServletResponse.SC_PRECONDITION_FAILED); return false; } } } catch(IllegalArgumentException illegalArgument) { return true; } return true; }
/** * Check if the if-unmodified-since condition is satisfied. * * @param request The servlet request we are processing * @param response The servlet response we are creating * @param resourceAttributes File object * @return boolean true if the resource meets the specified condition, * and false if the condition is not satisfied, in which case request * processing is stopped */ protected boolean checkIfUnmodifiedSince(HttpServletRequest request, HttpServletResponse response, ResourceAttributes resourceAttributes) throws IOException { try { long lastModified = resourceAttributes.getLastModified(); long headerValue = request.getDateHeader("If-Unmodified-Since"); if (headerValue != -1) { if ( lastModified >= (headerValue + 1000)) { // The entity has not been modified since the date // specified by the client. This is not an error case. response.sendError(HttpServletResponse.SC_PRECONDITION_FAILED); return false; } } } catch(IllegalArgumentException illegalArgument) { return true; } return true; }
/** * Check if the if-unmodified-since condition is satisfied. * * @param request The servlet request we are processing * @param response The servlet response we are creating * @param resourceAttributes File object * @return boolean true if the resource meets the specified condition, * and false if the condition is not satisfied, in which case request * processing is stopped */ protected boolean checkIfUnmodifiedSince(HttpServletRequest request, HttpServletResponse response, ResourceAttributes resourceAttributes) throws IOException { try { long lastModified = resourceAttributes.getLastModified(); long headerValue = request.getDateHeader("If-Unmodified-Since"); if (headerValue != -1) { if ( lastModified >= (headerValue + 1000)) { // The entity has not been modified since the date // specified by the client. This is not an error case. response.sendError(HttpServletResponse.SC_PRECONDITION_FAILED); return false; } } } catch(IllegalArgumentException illegalArgument) { return true; } return true; }
/** * Check if the if-unmodified-since condition is satisfied. * * @param request The servlet request we are processing * @param response The servlet response we are creating * @param resourceInfo File object * @return boolean true if the resource meets the specified condition, * and false if the condition is not satisfied, in which case request * processing is stopped */ protected boolean checkIfUnmodifiedSince(HttpServletRequest request, HttpServletResponse response, ResourceAttributes resourceAttributes) throws IOException { try { long lastModified = resourceAttributes.getLastModified(); long headerValue = request.getDateHeader("If-Unmodified-Since"); if (headerValue != -1) { if ( lastModified >= (headerValue + 1000)) { // The entity has not been modified since the date // specified by the client. This is not an error case. response.sendError(HttpServletResponse.SC_PRECONDITION_FAILED); return false; } } } catch(IllegalArgumentException illegalArgument) { return true; } return true; }
/** * Check if the if-unmodified-since condition is satisfied. * * @param request The servlet request we are processing * @param response The servlet response we are creating * @param resourceInfo File object * @return boolean true if the resource meets the specified condition, * and false if the condition is not satisfied, in which case request * processing is stopped */ protected boolean checkIfUnmodifiedSince(HttpServletRequest request, HttpServletResponse response, ResourceAttributes resourceAttributes) throws IOException { try { long lastModified = resourceAttributes.getLastModified(); long headerValue = request.getDateHeader("If-Unmodified-Since"); if (headerValue != -1) { if ( lastModified >= (headerValue + 1000)) { // The entity has not been modified since the date // specified by the client. This is not an error case. response.sendError(HttpServletResponse.SC_PRECONDITION_FAILED); return false; } } } catch(IllegalArgumentException illegalArgument) { return true; } return true; }
/** * Check if the if-unmodified-since condition is satisfied. * * @param request The servlet request we are processing * @param response The servlet response we are creating * @param resourceAttributes File object * @return boolean true if the resource meets the specified condition, * and false if the condition is not satisfied, in which case request * processing is stopped */ protected boolean checkIfUnmodifiedSince(HttpServletRequest request, HttpServletResponse response, ResourceAttributes resourceAttributes) throws IOException { try { long lastModified = resourceAttributes.getLastModified(); long headerValue = request.getDateHeader("If-Unmodified-Since"); if (headerValue != -1) { if ( lastModified >= (headerValue + 1000)) { // The entity has not been modified since the date // specified by the client. This is not an error case. response.sendError(HttpServletResponse.SC_PRECONDITION_FAILED); return false; } } } catch(IllegalArgumentException illegalArgument) { return true; } return true; }
/** * Check if the if-unmodified-since condition is satisfied. * * @param request The servlet request we are processing * @param response The servlet response we are creating * @param resourceAttributes File object * @return boolean true if the resource meets the specified condition, * and false if the condition is not satisfied, in which case request * processing is stopped */ protected boolean checkIfUnmodifiedSince(HttpServletRequest request, HttpServletResponse response, ResourceAttributes resourceAttributes) throws IOException { try { long lastModified = resourceAttributes.getLastModified(); long headerValue = request.getDateHeader("If-Unmodified-Since"); if (headerValue != -1) { if ( lastModified >= (headerValue + 1000)) { // The entity has not been modified since the date // specified by the client. This is not an error case. response.sendError(HttpServletResponse.SC_PRECONDITION_FAILED); return false; } } } catch(IllegalArgumentException illegalArgument) { return true; } return true; }
/** * Check if the if-unmodified-since condition is satisfied. * * @param request The servlet request we are processing * @param response The servlet response we are creating * @param resourceAttributes File object * @return boolean true if the resource meets the specified condition, * and false if the condition is not satisfied, in which case request * processing is stopped */ protected boolean checkIfUnmodifiedSince(HttpServletRequest request, HttpServletResponse response, ResourceAttributes resourceAttributes) throws IOException { try { long lastModified = resourceAttributes.getLastModified(); long headerValue = request.getDateHeader("If-Unmodified-Since"); if (headerValue != -1) { if ( lastModified >= (headerValue + 1000)) { // The entity has not been modified since the date // specified by the client. This is not an error case. response.sendError(HttpServletResponse.SC_PRECONDITION_FAILED); return false; } } } catch(IllegalArgumentException illegalArgument) { return true; } return true; }
/** * Check if the if-unmodified-since condition is satisfied. * * @param request The servlet request we are processing * @param response The servlet response we are creating * @param resourceAttributes File object * @return boolean true if the resource meets the specified condition, * and false if the condition is not satisfied, in which case request * processing is stopped */ protected boolean checkIfUnmodifiedSince(HttpServletRequest request, HttpServletResponse response, ResourceAttributes resourceAttributes) throws IOException { try { long lastModified = resourceAttributes.getLastModified(); long headerValue = request.getDateHeader("If-Unmodified-Since"); if (headerValue != -1) { if ( lastModified >= (headerValue + 1000)) { // The entity has not been modified since the date // specified by the client. This is not an error case. response.sendError(HttpServletResponse.SC_PRECONDITION_FAILED); return false; } } } catch(IllegalArgumentException illegalArgument) { return true; } return true; }
try { long headerValue = request.getDateHeader("If-Modified-Since"); long lastModified = resourceAttributes.getLastModified(); if (headerValue != -1) {
try { long headerValue = request.getDateHeader("If-Modified-Since"); long lastModified = resourceAttributes.getLastModified(); if (headerValue != -1) {
try { long headerValue = request.getDateHeader("If-Modified-Since"); long lastModified = resourceAttributes.getLastModified(); if (headerValue != -1) {
/** * Revalidate entry. */ protected boolean revalidate(CacheEntry entry) { // Get the attributes at the given path, and check the last // modification date if (!entry.exists) return false; if (entry.attributes == null) return false; long lastModified = entry.attributes.getLastModified(); long contentLength = entry.attributes.getContentLength(); if (lastModified <= 0) return false; try { Attributes tempAttributes = dirContext.getAttributes(entry.name); ResourceAttributes attributes = null; if (!(tempAttributes instanceof ResourceAttributes)) { attributes = new ResourceAttributes(tempAttributes); } else { attributes = (ResourceAttributes) tempAttributes; } long lastModified2 = attributes.getLastModified(); long contentLength2 = attributes.getContentLength(); return (lastModified == lastModified2) && (contentLength == contentLength2); } catch (NamingException e) { return false; } }
/** * Revalidate entry. */ protected boolean revalidate(CacheEntry entry) { // Get the attributes at the given path, and check the last // modification date if (!entry.exists) return false; if (entry.attributes == null) return false; long lastModified = entry.attributes.getLastModified(); long contentLength = entry.attributes.getContentLength(); if (lastModified <= 0) return false; try { Attributes tempAttributes = dirContext.getAttributes(entry.name); ResourceAttributes attributes = null; if (!(tempAttributes instanceof ResourceAttributes)) { attributes = new ResourceAttributes(tempAttributes); } else { attributes = (ResourceAttributes) tempAttributes; } long lastModified2 = attributes.getLastModified(); long contentLength2 = attributes.getContentLength(); return (lastModified == lastModified2) && (contentLength == contentLength2); } catch (NamingException e) { return false; } }
/** * Revalidate entry. */ protected boolean revalidate(CacheEntry entry) { // Get the attributes at the given path, and check the last // modification date if (!entry.exists) return false; if (entry.attributes == null) return false; long lastModified = entry.attributes.getLastModified(); long contentLength = entry.attributes.getContentLength(); if (lastModified <= 0) return false; try { Attributes tempAttributes = dirContext.getAttributes(entry.name); ResourceAttributes attributes = null; if (!(tempAttributes instanceof ResourceAttributes)) { attributes = new ResourceAttributes(tempAttributes); } else { attributes = (ResourceAttributes) tempAttributes; } long lastModified2 = attributes.getLastModified(); long contentLength2 = attributes.getContentLength(); return (lastModified == lastModified2) && (contentLength == contentLength2); } catch (NamingException e) { return false; } }
/** * Revalidate entry. */ protected boolean revalidate(CacheEntry entry) { // Get the attributes at the given path, and check the last // modification date if (!entry.exists) return false; if (entry.attributes == null) return false; long lastModified = entry.attributes.getLastModified(); long contentLength = entry.attributes.getContentLength(); if (lastModified <= 0) return false; try { Attributes tempAttributes = dirContext.getAttributes(entry.name); ResourceAttributes attributes = null; if (!(tempAttributes instanceof ResourceAttributes)) { attributes = new ResourceAttributes(tempAttributes); } else { attributes = (ResourceAttributes) tempAttributes; } long lastModified2 = attributes.getLastModified(); long contentLength2 = attributes.getContentLength(); return (lastModified == lastModified2) && (contentLength == contentLength2); } catch (NamingException e) { return false; } }
/** * Revalidate entry. */ protected boolean revalidate(CacheEntry entry) { // Get the attributes at the given path, and check the last // modification date if (!entry.exists) return false; if (entry.attributes == null) return false; long lastModified = entry.attributes.getLastModified(); long contentLength = entry.attributes.getContentLength(); if (lastModified <= 0) return false; try { Attributes tempAttributes = dirContext.getAttributes(entry.name); ResourceAttributes attributes = null; if (!(tempAttributes instanceof ResourceAttributes)) { attributes = new ResourceAttributes(tempAttributes); } else { attributes = (ResourceAttributes) tempAttributes; } long lastModified2 = attributes.getLastModified(); long contentLength2 = attributes.getContentLength(); return (lastModified == lastModified2) && (contentLength == contentLength2); } catch (NamingException e) { return false; } }
/** * Revalidate entry. */ protected boolean revalidate(CacheEntry entry) { // Get the attributes at the given path, and check the last // modification date if (!entry.exists) return false; if (entry.attributes == null) return false; long lastModified = entry.attributes.getLastModified(); long contentLength = entry.attributes.getContentLength(); if (lastModified <= 0) return false; try { Attributes tempAttributes = dirContext.getAttributes(entry.name); ResourceAttributes attributes = null; if (!(tempAttributes instanceof ResourceAttributes)) { attributes = new ResourceAttributes(tempAttributes); } else { attributes = (ResourceAttributes) tempAttributes; } long lastModified2 = attributes.getLastModified(); long contentLength2 = attributes.getContentLength(); return (lastModified == lastModified2) && (contentLength == contentLength2); } catch (NamingException e) { return false; } }
/** * Get the ETag associated with a file. * * @param resourceAttributes The resource information */ protected String getETag(ResourceAttributes resourceAttributes) { String result = null; if ((result = resourceAttributes.getETag(true)) != null) { return result; } else if ((result = resourceAttributes.getETag()) != null) { return result; } else { return "W/\"" + resourceAttributes.getContentLength() + "-" + resourceAttributes.getLastModified() + "\""; } }