Hi Andy,The use of AuditDateImpl.getLatestDate is the problem (and a bit dense of me…)
thank you for finding the problem. : )I can see in org.alfresco.repo.audit.hibernate.HibernateAuditDAO.getAuditDatethe method AuditDateImpl.getLatestDate is used.And it is to get the maximum id (natively generated by the database)as described in Audit.hbm.xmlI see the problem may lies in the code HibernateAuditDAO.getAuditDatewhere in the while loop with every loop it is incrementing the date taken from alf_audit_date database by 1 day each timeand then compare it to "AuditState auditInfo"'s date… (both date having set hr, min, sec, millisec as 0)
while (!required.equals(auditDate.getDate()))
{
Date nextDate = Duration.add(auditDate.getDate(), new Duration("P1D"));
auditDate = new AuditDateImpl(nextDate);
getSession().save(auditDate);
auditDateImplId.set(Long.valueOf(auditDate.getId()));
}
we still have to change the code to make it runs…have you got fix and have the solution? please post it : )(I am testing on alfresco 2.1)How are we going to change this so getting latest date that might be 10 years ahead, will not ruin the alfresco to load and have it running normal and its audit module will work as usual?I am thinking of modifying this simply to
if (!required.equals(auditDate.getDate()))
{
auditDate = new AuditDateImpl(required);
getSession().save(auditDate);
auditDateImplId.set(Long.valueOf(auditDate.getId()));
}
without the unnecessary while loop and having the date set hopefully back from perhaps 10 years ahead to today's date!?If "AuditState auditInfo"'s date which is variable "required" - is today's date.…ResultI tested fast foward the date a month ahead, then reverse the date back to today's date.Shut server down each down and start it up.The good news:
The alfresco 2.1 seem to be working with this change.
The not as good news:(1)However I can not guarantee that this won't affect any audit relating things?If ok please tell me if that will work ok with the rest of application : )(2)Also I find alfresco can not cope with me fast forwarding the date while it is running. After fast forward the date (a month) without shutting alfresco server down. It automatically log me out, and when I login… I waited and waited…alfresco server - the JVM memory then keeps on climbing…It seem to be in an infinite loop…This I think is a sort of defect… at least is not as critical as previous one, can live with.Thank you.jl