/**
* check if the file corresponding to the object is newer than the given timestamp and remove the file from {@link #files}.
*/
@Override
protected boolean checkUpToDate(String identifyer, Object timestamp, String timestampattribute, Resolvable object) {
CRResolvableBean bean = new CRResolvableBean(object);
if (!"10002".equals(bean.getObj_type())) {
String publicationDirectory;
if (ignorePubDir) {
publicationDirectory = "";
} else {
publicationDirectory = bean.getString("pub_dir");
}
String filename = bean.getString("filename");
assertNotNull("Bean " + bean.getContentid() + " has no attribute pub_dir.", publicationDirectory);
assertNotNull("Bean " + bean.getContentid() + " has no attribute filename.", filename);
if (logger.isDebugEnabled()) {
logger.debug("Checking " + publicationDirectory + filename + ".");
}
Integer updatetimestamp = null;
if (timestamp instanceof Integer) {
updatetimestamp = (Integer) timestamp;
} else if (timestamp instanceof Long) {
logger.warn("You are giving me a Long as updatetimestamp. The API at indexUpdateChecker#checkUpToDate says you shouldn't. "
+ "This can lead to troubles. I'm assuming the timestamp is in milliseconds not in seconds.");
updatetimestamp = (int) ((Long) timestamp / 1000L);
}
File file = new File(new File(directory, publicationDirectory), filename);
removeFileFromDeletionList(publicationDirectory + filename);
if (file.exists() && file.isFile() && (file.lastModified() / 1000) >= updatetimestamp) {
return true;
}
} else if (!ignorePubDir) {
//it would just make no sense to check for check for folders existence if the pub_dir attribute is ignored
String publicationDirectory = bean.getString("pub_dir");
File file = new File(directory, publicationDirectory);
removeFileFromDeletionList(publicationDirectory);
if (file.exists() && file.isDirectory()) {
return true;
}