protected Image toUnwrappedModel(Image image) { if (image instanceof ImageImpl) { return image; } ImageImpl imageImpl = new ImageImpl(); imageImpl.setNew(image.isNew()); imageImpl.setPrimaryKey(image.getPrimaryKey()); imageImpl.setImageId(image.getImageId()); imageImpl.setModifiedDate(image.getModifiedDate()); imageImpl.setText(image.getText()); imageImpl.setType(image.getType()); imageImpl.setHeight(image.getHeight()); imageImpl.setWidth(image.getWidth()); imageImpl.setSize(image.getSize()); return imageImpl; }
@Override protected long getLastModified(HttpServletRequest request) { try { Date modifiedDate = null; Image image = getImage(request, true); if (image != null) { modifiedDate = image.getModifiedDate(); } else { String path = HttpUtil.fixPath(request.getPathInfo()); String[] pathArray = StringUtil.split(path, CharPool.SLASH); if (pathArray.length == 0) { return -1; } if (pathArray[0].equals("language")) { return -1; } FileEntry fileEntry = null; try { fileEntry = getFileEntry(pathArray); } catch (Exception e) { } if (fileEntry == null) { return -1; } else { String version = ParamUtil.getString(request, "version"); if (Validator.isNotNull(version)) { FileVersion fileVersion = fileEntry.getFileVersion(version); modifiedDate = fileVersion.getModifiedDate(); } else { modifiedDate = fileEntry.getModifiedDate(); } } } if (modifiedDate == null) { modifiedDate = PortalUtil.getUptime(); } // Round down and remove milliseconds return (modifiedDate.getTime() / 1000) * 1000; } catch (PrincipalException pe) { if (_log.isWarnEnabled()) { _log.warn(pe, pe); } } catch (Exception e) { _log.error(e, e); } return -1; }