public long getLastModified(HttpServletRequest request) { String path = request.getParameter("path"); if (StringUtils.trimToNull(path) == null) { return 0; } File file = new File(path); if (!FileUtil.exists(file)) { return -1; } return FileUtil.lastModified(file); }
public long getLastModified(HttpServletRequest request) { try { File file = getImageFile(request); if (file == null) { return 0; // Request for the default image. } if (!FileUtil.exists(file)) { return -1; } return FileUtil.lastModified(file); } catch (Exception e) { return -1; } }
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception { File file = getImageFile(request); if (file != null && !FileUtil.exists(file)) { response.sendError(HttpServletResponse.SC_NOT_FOUND); return null; } // Check access. if (file != null && !securityService.isReadAllowed(file)) { response.sendError(HttpServletResponse.SC_FORBIDDEN); return null; } // Send default image if no path is given. (No need to cache it, since it will be cached in // browser.) Integer size = ServletRequestUtils.getIntParameter(request, "size"); boolean typArtist = ServletRequestUtils.getBooleanParameter(request, "typArtist", false); if (typArtist == true) { if (file == null) { sendDefaultArtist(size, response); return null; } } else { if (file == null) { sendDefault(size, request, response); return null; } } // Optimize if no scaling is required. if (size == null) { sendUnscaled(file, response); return null; } // Send cached image, creating it if necessary. try { File cachedImage = getCachedImage(file, size); sendImage(cachedImage, response); } catch (IOException e) { sendDefault(size, request, response); } return null; }
public boolean exists() { return FileUtil.exists(getFile()); }